BookmarkSubscribeRSS Feed
teg_76
Calcite | Level 5

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!

    

        

2 REPLIES 2
Tom
Super User Tom
Super User

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;

Ksharp
Super User

Plus, If grp is character ,then don't forget to add quote around it.

Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 639 views
  • 0 likes
  • 3 in conversation