LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2006, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 30 Apr 2006 11:49:10 -0500
Reply-To:     "Gregg P. Snell" <sas-l@DATASAVANTCONSULTING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Gregg P. Snell" <sas-l@DATASAVANTCONSULTING.COM>
Subject:      Re: How to automatically change data name in SET?
Comments: To: lei <leiliang217@YAHOO.COM>
In-Reply-To:  <1146409449.490371.74320@g10g2000cwb.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

Lei,

There certainly is. Here is one solution you can write and execute with nothing more than base SAS to avoid the arcane and obscure scl:

proc sql noprint; select memname into :datasets separated by " " from sashelp.vtable where libname="SUBRO" and memname like "MYDATA%"; quit;

%put datasets=&datasets;

data subro.result; set &datasets; run;

You may need to tweak the where clause to be sure it selects only the tables you are interested in.

Regards,

Gregg Snell

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of lei Sent: Sunday, April 30, 2006 10:04 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to automatically change data name in SET?

Hi everyone,

I have a question. I have a few datasets, say mydata1, mydata2, mydata3, till mydata&M where M is dymically changing according to month. For example in March M=3, in April M=4. So I wrote a program like this but got error message

DATA SUBRO.RESULT; DO I = 1 TO &m; SET SUBRO.MYDATA&I; END RUN;

The effect I want to achieve is that, for example, for m = 3 DATA SUBRO.RESULT; SET SUBRO.MYDATA1; SET SUBRO.MYDATA2; SET SUBRO.MYDATA3; RUN;

for m = 4, it becomes DATA SUBRO.RESULT; SET SUBRO.MYDATA1; SET SUBRO.MYDATA2; SET SUBRO.MYDATA3; SET SUBRO.MYDATA4; RUN;

Is there any way to do this?

Thank you!


Back to: Top of message | Previous page | Main SAS-L page