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 (December 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 22 Dec 2008 17:35:13 +0530
Reply-To:     Anindya Mozumdar <anindya.lugbang@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Anindya Mozumdar <anindya.lugbang@GMAIL.COM>
Subject:      Re: Splitting a large dataset
Comments: To: karma <dorjetarap@googlemail.com>
In-Reply-To:  <d6a0d8f10812220359v43b1100eib3cbfa96420b2b62@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Oops... I never understood call execute correctly... however, the slight disadvantage to the above is that there are multiple data steps which are executed (one for each name), and it may be an efficiency issue for large datasets.

OP, my solution will not work if your names contain spaces or special characters... you need to modify it by using COMPRESS so that your output dataset names contain only numbers, characters or underscores.

On Mon, Dec 22, 2008 at 5:29 PM, karma <dorjetarap@googlemail.com> wrote: > Or call execute > > data test; > input name $ data $; > cards; > Jens A > Jens G > Jens X > Ole D > Ole B > ;run; > > data _null_; > set test; > by name; > if first.name then > call execute(catx(' ','data',name, > '; set test;', > 'where name =',quote(name),';' > ,'run;')); > run; > > 2008/12/22 Anindya Mozumdar <anindya.lugbang@gmail.com>: >> A slightly more general solution to the one above - >> >> data test; >> input name $ data $; >> datalines; >> Jens A >> Jens G >> Jens X >> Ole D >> Ole B >> ; >> run; >> >> proc sql noprint; >> select distinct upcase(name) into :distnames separated by '|' >> from test; >> quit; >> %let cntnames = %sysfunc(countc(&distnames, |)); >> %let cntnames = %eval(&cntnames + 1); >> %put &cntnames &distnames; >> >> %macro splitDs(); >> >> data %do i = 1 %to &cntnames; test_%scan(&distnames,&i, |) %end;; >> set test; >> %do i = 1 %to &cntnames; >> %let currname = %scan(&distnames,&i, |); >> if trim(upcase(name)) = "&currname" >> then output test_%scan(&distnames,&i, |); >> %end; >> run; >> >> %mend splitDs; >> >> %splitDs() >> >


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