From: Jay on
Suppose I have a dataset like
VAR VAL
C2 2
B9 3
D4 4
.... ...
How do I create macro variables C2, B9, D4 etc and assign them the
corresponding values?

many thanks
From: Paige Miller on
On May 26, 4:09 pm, Jay <jingsi....(a)gmail.com> wrote:
> Suppose I have a dataset like
> VAR     VAL
> C2        2
> B9        3
> D4        4
> ...         ...
> How do I create macro variables C2, B9, D4 etc and assign them the
> corresponding values?
>
> many thanks

CALL SYMPUT function

--
Paige MIller
paige\dot\miller \at\ kodak\dot\com
From: Jay on
On May 26, 4:26 pm, Paige Miller <paige.mil...(a)kodak.com> wrote:
> On May 26, 4:09 pm, Jay <jingsi....(a)gmail.com> wrote:
>
> > Suppose I have a dataset like
> > VAR VAL
> > C2 2
> > B9 3
> > D4 4
> > ... ...
> > How do I create macro variables C2, B9, D4 etc and assign them the
> > corresponding values?
>
> > many thanks
>
> CALL SYMPUT function
>
> --
> Paige MIller
> paige\dot\miller \at\ kodak\dot\com


something like

data _null_;
set something;
call symput(%var,&val);
run;

i want the system to read a observation, assign the value of var to a
macro variable of that name and assign val as its value

thanks again
From: Ya on
On May 26, 1:40 pm, Jay <jingsi....(a)gmail.com> wrote:
> On May 26, 4:26 pm, Paige Miller <paige.mil...(a)kodak.com> wrote:
>
>
>
>
>
> > On May 26, 4:09 pm, Jay <jingsi....(a)gmail.com> wrote:
>
> > > Suppose I have a dataset like
> > > VAR     VAL
> > > C2        2
> > > B9        3
> > > D4        4
> > > ...         ...
> > > How do I create macro variables C2, B9, D4 etc and assign them the
> > > corresponding values?
>
> > > many thanks
>
> > CALL SYMPUT function
>
> > --
> > Paige MIller
> > paige\dot\miller \at\ kodak\dot\com
>
> something like
>
> data _null_;
>         set something;
>         call symput(%var,&val);
> run;
>
> i want the system to read a observation, assign the value of var to a
> macro variable of that name and assign val as its value
>
> thanks again- Hide quoted text -
>
> - Show quoted text -

data xx;
input VAR $ VAL;
cards;
C2 2
B9 3
D4 4
;

proc sql noprint;
select resolve('%let '||trim(var)||'='||trim(put(val,best.-l))||';')
into :dummy separated by ' '
from xx
;

%put _user_;

GLOBAL D4 4
GLOBAL B9 3
GLOBAL DUMMY
GLOBAL C2 2

HTH

Ya
From: Barry Schwarz on
On Wed, 26 May 2010 13:40:11 -0700 (PDT), Jay <jingsi.tan(a)gmail.com>
wrote:

>On May 26, 4:26 pm, Paige Miller <paige.mil...(a)kodak.com> wrote:
>> On May 26, 4:09 pm, Jay <jingsi....(a)gmail.com> wrote:
>>
>> > Suppose I have a dataset like
>> > VAR VAL
>> > C2 2
>> > B9 3
>> > D4 4
>> > ... ...
>> > How do I create macro variables C2, B9, D4 etc and assign them the
>> > corresponding values?
>>
>> > many thanks
>>
>> CALL SYMPUT function
>>
>> --
>> Paige MIller
>> paige\dot\miller \at\ kodak\dot\com
>
>
>something like
>
>data _null_;
> set something;
> call symput(%var,&val);
>run;
>
>i want the system to read a observation, assign the value of var to a
>macro variable of that name and assign val as its value

Neither argument to symput should have any special characters. var
contains the name of the macro variable you want to create. val
contains the value you want to assign to that macro variable.

--
Remove del for email