BookmarkSubscribeRSS Feed
abdullala
Calcite | Level 5
data test;
input grp1 grp2 count cntvarname;
cards
1 1 8 g1_g1
1 2 9 g1_g2
1 3 7 g1_g3
2 1 5 g2_g1
2 2 6 g2_g2
;

How do I assign each of the count values to a macro variable whose name is defined in cntvarname? that is, I want a macro variable g1_g1 has value 8, g1_g2 =9, etc.

proc sql select into: needs a resolved macro variable name. I can not get this work. much appreciate for help!
3 REPLIES 3
data_null__
Jade | Level 19
For this a data step with CALL SYMPUTX would be easier.

However, why do it at all. The data is much more useful in a data set than in macro variables. Once the data are in macro variables that are mostly useless because you have to know their names, and the values are not longer numbers, etc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
At times, I also find this condition to work best with macro variables, mostly where a SAS variable label (or a TITLEn maybe) requires the contents of an incoming SAS variable to be revealed in a report, instead of occupying a column. One example would be event response metrics data where a variable declares some distribution limit value, like "all responses less than &respval1" when used as an associated metric variable label.

Scott Barry
SBBWorks, Inc.
abdullala
Calcite | Level 5
thank you all, I should use call symput. yes, I need all those in macro variables to be called in some other places.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1020 views
  • 0 likes
  • 3 in conversation