Hi,
I'd like to store a a list of values from a file in a file in a macro variable. I then would like to select all the rows from a dataset that do not have a value stored in the macro variable. HEre's what I have so far:
proc sql;
select grp sum(total)
from claims
where grp not in (&list);
quit;
How do I get the variables in to the "list" macro variable? The values that should populate the "list" macro variable are from a column in a csv file.
Thank you!
First put it in a dataset.
data exclude ;
infile 'exclude.csv' dsd firstobs=2;
input grp;
run;
Then ... Since you have it in a dataset forget about the macro variable and just use the dataset in the query.
If you must put it into a macro variable use the INTO clause in PROC SQL select statement.
proc sql noprint ;
select distinct grp into :list separated by ' '
from exclude
;
quit;
Plus, If grp is character ,then don't forget to add quote around it.
Ksharp
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.