Hello
I want to create multiple macro variables based on the data set macro_var_help.
In the data set 2 columns(First columns is values ,Second column is macro var name)
The following macro variables should be created:
Today(value 1903)
NextQ(value 1906)
Q3(value 1912)
Jan21(value 2101)
Apr21(value2104)
last(value2108),
What is the way to do it based on the data set values?
Data macro_var_help;
input YYMM name $;
cards;
1903 Today
1906 NextQ
1912 Q3
2101 Jan21
2104 Apr21
2108 last
;
Run;
CALL SYMPUTX(), look at the third parameter option in the documentation to control if it's a global or local macro variable.
data _null_;
set macro_var_help;
call symputx(name, YYMM);
run;
%put &today.;
%put &Jan21.;
%put &Q3.;
%put &last.;
@Ronein wrote:
Hello
I want to create multiple macro variables based on the data set macro_var_help.
In the data set 2 columns(First columns is values ,Second column is macro var name)
The following macro variables should be created:
Today(value 1903)
NextQ(value 1906)
Q3(value 1912)
Jan21(value 2101)
Apr21(value2104)
last(value2108),
What is the way to do it based on the data set values?
Data macro_var_help; input YYMM name $; cards; 1903 Today 1906 NextQ 1912 Q3 2101 Jan21 2104 Apr21 2108 last ; Run;
CALL SYMPUTX(), look at the third parameter option in the documentation to control if it's a global or local macro variable.
data _null_;
set macro_var_help;
call symputx(name, YYMM);
run;
%put &today.;
%put &Jan21.;
%put &Q3.;
%put &last.;
@Ronein wrote:
Hello
I want to create multiple macro variables based on the data set macro_var_help.
In the data set 2 columns(First columns is values ,Second column is macro var name)
The following macro variables should be created:
Today(value 1903)
NextQ(value 1906)
Q3(value 1912)
Jan21(value 2101)
Apr21(value2104)
last(value2108),
What is the way to do it based on the data set values?
Data macro_var_help; input YYMM name $; cards; 1903 Today 1906 NextQ 1912 Q3 2101 Jan21 2104 Apr21 2108 last ; Run;
Use the CALL SYMPUTX Routine.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.