BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I have a list of over 2,000 variables.

To run a query on them I need to use the following code:

where variable in ('xxx1', 'xxx2', 'xxx3',....etc)

The variables are currently in the format of: xxx1 xxx2 xxx3

Is there a short cut to format the variables so i do not have to manually add ' ' , (the neccessary punctuation) to each of the variables?

Any help most appreciated!
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
From the SAS support website and its incredible resource of code snippets and examples -- which I found using a GOOGLE.COM advanced search with site:sas.com to limit the search:

Sample 25976: Create a macro variable that contains a quoted list
http://support.sas.com/kb/25/976.html


Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thanks so much for that Scott!

That code was very helpful.

Is it possible to keep the newly punctuated variables just as a data set?

i.e. I do not need the following:

data master;
input empl $ job $;
datalines;
12345 clerk
34567 rep
00001 analyst
;

proc print data=master;
where empl in(&list);
run;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Use PROC SQL to generate the macro variable, as demonstrated. Then code a DATA step with a RETAIN statement, specifying your desired SAS data variable name, and initialize the variable with the "generated" SAS macro variable, specified in double-quotes (not single-quotes -- otherwise the macro var is not going to be resolved).

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
I ended up concatenating the data in excel because it was the code I needed to format & not the output.

Thanks for your help.

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!

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.

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
  • 4 replies
  • 610 views
  • 0 likes
  • 2 in conversation