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 (June 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 18 Jun 1996 22:13:09 -0600
Reply-To:     Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Organization: Cary Consulting Services
Subject:      Re: A question on proc sql.

YFLI@LANDRU.CPR.UPENN.EDU wrote: > > I have a clinical data set with 79 observations on some 100 > variables. From this 79 by 100 data set, I want to select 50 > variables out, and form a new sub-data set. One way to do this is to > use a proc sql as follows; > > proc sql; > create table new as > select (list of 50 variables) > from (data set name); > quit; > > I am wondering if there is a simpler way to select the 50 variables > in proc sql, instead of listing each single one of them. > Suppose the 50 variables' names have a sequential number attached > to them, > e.g. the names of the 50 variables could be "x1,x2,x3,....,x52, x53". > > I have tried to use "select x1-x53" in the proc sql, it does not work. > > Thanks. > > -Paul

Here's a cheap trick.

Define a macro called list to build your list.

%MACRO BUILDCDL(Prefix,start,stop); %DO I=&START %TO %eval(&STOP-1); &PREFIX&I, %END; &PREFIX&STOP %MEND BUILDCDL;

and use it in your SQL;

PROC SQL; SELECT %BUILDCDL(Y,50,75) FROM test;

-- Andrew J. L. Cary | I Reckon that the Opinions Senior Curmudgeon | expressed here DO represent Cary Consulting Services, Newark, CA | those of the management of ajlcary@ix.netcom.com | Cary Consulting Services


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