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.
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.