Help using Base SAS procedures

proc sql select

Reply
Contributor
Posts: 74

proc sql select

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!
Respected Advisor
Posts: 3,799

Re: proc sql select

Posted in reply to abdullala
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.
Super Contributor
Super Contributor
Posts: 3,174

Re: proc sql select

Posted in reply to data_null__
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.
Contributor
Posts: 74

Re: proc sql select

thank you all, I should use call symput. yes, I need all those in macro variables to be called in some other places.
Ask a Question
Discussion stats
  • 3 replies
  • 155 views
  • 0 likes
  • 3 in conversation