Hi All,
I have a dataset named " masterdataset" looks like below
type | Count |
A | 223 |
B | 123 |
C | 343 |
D | 767 |
E | 233 |
I want to convert every individual rows in to individual macros. Eg: if i will do %put &=A then the result should be 223.
Tried to do with proc sql , but getting error
proc sql;
select distinct typeinto :groupA_bign-:groupB_bign from masterdataset;
quit;
ERROR: The following columns were not found in the contributing tables: masterdataset.
Kindly let me know if there is any other way to do this or how to modify the code to get the result.
Use the Swiss Army Knife of SAS processing, the data step:
data _null_;
set masterdataset;
call symputx(type,count);
run;
Use the Swiss Army Knife of SAS processing, the data step:
data _null_;
set masterdataset;
call symputx(type,count);
run;
@sahoositaram555 wrote:
Thanks,
It worked. @Kurt_Bremser Any comment/valuable inputs on proc sql statement which i have provided?
SQL does not support the dynamic creation of macro variable names from dataset columns, so it would be extremely clumsy to somehow re-engineer the call symput(x) function with it:
This algorithm is just a suggestion, not tested in any way. I'm not sure if the obs= and firstobs= dataset options work in proc sql.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.