DATA Step, Macro, Functions and more

Assigning data set values to macro variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Assigning data set values to macro variables

Hi forum,

I have data set Sample like below
Var1 var2
Id a123
Name KKK

Var1 and var2 are column names.
I would like to create macro variables in names mentioned in var1 and assign the corresponding values in var2 to them.
Kindly help.




Accepted Solutions
Solution
‎12-26-2017 07:27 AM
SAS Super FREQ
Posts: 496

Re: Assigning data set values to macro variables

data _null_;
input Var1 $ var2 $;
call symputx(var1, var2);
datalines;
Id a123
Name LLL
;
%put &id &name;

View solution in original post


All Replies
Solution
‎12-26-2017 07:27 AM
SAS Super FREQ
Posts: 496

Re: Assigning data set values to macro variables

data _null_;
input Var1 $ var2 $;
call symputx(var1, var2);
datalines;
Id a123
Name LLL
;
%put &id &name;
Occasional Contributor
Posts: 10

Re: Assigning data set values to macro variables

Thanks
Occasional Contributor
Posts: 10

Assigning data set values to macro variables

Hi forum,

I have data set Sample like below
Var1 var2
Id a123
Name KKK

Var1 and var2 are column names.
I would like to create macro variables in names mentioned in var1 and adding the corresponding values in var2 to them.
Kindly help


☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 178 views
  • 1 like
  • 2 in conversation