Date: Mon, 22 Dec 2008 12:41:24 -0800
Reply-To: jesper@HVIDKILDEHUSENE.DK
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: jesper@HVIDKILDEHUSENE.DK
Organization: http://groups.google.com
Subject: Re: Splitting a large dataset
Content-Type: text/plain; charset=ISO-8859-1
On 22 Dec., 12:40, anindya.lugb...@GMAIL.COM (Anindya Mozumdar) wrote:
> 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()
Thank you very much for your answers - everyone. It is very
appreciated.
I have used the macro-code above and it works perfectly when I use
numbers instead of names. There is a number attached to each person
(almost, some of the persons have two numbers and thats why I rather
will use the names than the numbers). I will figure out how to do it
with the names (use underscore instead of space) when I get back to
work after christmas :-) No use for help.
Thanks
|