Good Morning!,
I know this question might be silly but I am trying to achieve the following:
(1) I have a variable for instance: %let Var1 = A B C;
Then I want to pass it in a Dataset column such that
data want;
WantedColumn = &Var1;
run;
However, this does not work. I have tried several combinations with PUT and SCAN but havent found the good one.
How is it done ??
Thank you for your time !,
Then do
%let Var1 = A B C;
data want(drop=i);
do i=1 to countw("&Var1");
WantedColumn=scan("&Var1", i);
output;
end;
run;
Put quotes around your macro variable
%let Var1 = A B C;
data want;
WantedColumn = "&Var1";
run;
This outputs me everything in one place but i want :
WantedColumn
A
B
C
NOT
Wanted Column
A B C
Then do
%let Var1 = A B C;
data want(drop=i);
do i=1 to countw("&Var1");
WantedColumn=scan("&Var1", i);
output;
end;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.