BookmarkSubscribeRSS Feed
tulip
Calcite | Level 5
data structure:
var1same var2same var3same------var100same

I donot want to list them all one by one when I look at them like following.
proc means;
var var1same var2same var3same------var100same;
run;

Is there a short cut way to list these similar variables without typing them all?

Thanks.
2 REPLIES 2
Patrick
Opal | Level 21
Hi Jenn

Just read Olivier's answer to your last question:
"You can use this shortcut : VAR var2: ; which stands for 'all variables having their name beginning with "VAR2" '

So why don't you just write "VAR var:" ?

Below my more complicated approach before Olivier reminded me how to do things.

You can also use a syntax like "VAR x -- c". This gives you all the variables like they are stored in the table (NOT alphabetically: it's COLNUM! This returns all the vars between Colnum of X to Colnum of C).

HTH
Patrick

data have;
a=1;
c=2;
var1same=97;
b=3;
d1=4;
var3same=98;
d2=5;
d10=6;
var2same=99;
d5=7;
output;
run;

%let VarList=;
proc sql;
select name into :VarList separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE' and upcase(name) like upcase('var%same')
order by name;
%put &VarList;
quit;

proc means;
var &VarList;
run;

Message was edited by: Patrick
tulip
Calcite | Level 5
Hi, Patrick:

Thanks for your reply.

By the way, the reason I could not use the olivier's short cut is that if I use var:, it will read more than necessary. There are hundreds of variable started with var.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 733 views
  • 0 likes
  • 2 in conversation