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 (November 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 6 Nov 2009 12:48:24 -0500
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: how to split data set
Content-Type: text/plain; charset=ISO-8859-1

you cannot split the dataset according to a variable, only to the CONTENTS of that variable. For that it is necessary to find out what that contents are and how many datasets you want to have as result. Example: you have a dataset with 1 million obs and the split variable is a primary key (no duplicates). If you want to use that variable as split variable, you cannot use simply the content 1:1, because then you will get 1 million datasets! If there are let's say 10 different contents in that variable, next question is, how they are distributed. If you have 9 different values in the first 9 obs and the rest all have the same content, that is not what you want. In that case you would get 10 datasets, 9 with 1 obs and one with 1 million. If the 10 obs are evenly distributed and have many values, e.g a counter, there might be a way to get the smalles, the biggest and divide that range in 10 parts. Then use that as delimiter like

if split <1000 then output out1; if 1000 <= split < 2000 then output out2; if ....

Hope that helps.

Gerhard

On Fri, 6 Nov 2009 09:24:32 -0800, nickyli <nickyli0753@GMAIL.COM> wrote:

>On 11月6日, 下午10时58分, gerhard.hellrie...@T-ONLINE.DE (Gerhard >Hellriegel) wrote: >> don't know for sure what you mean. It might be the question, how you can >> split a dataset by the VALUES (contents) of a variable. >> If you know the contents, you could use something like: >> >> data a b; >> � set big; >> � if x="a" then output a; >> � else output b; >> run; >> >> if not, you could also use a macro: >> >> %macro split(ds=,var=); >> � %let no=0; >> � proc sort data=&ds(keep=&var) out=temp nodupkey; >> � � by &var; >> � run; >> � data _null_; >> � � set temp; >> � � call symput("v"!!put(_n_,8. -L),&var); >> � � call symputx("no",_n_); >> � run; >> >> � data >> � � %do i=1 %to &no; >> � � � out&i >> � � %end; >> � � ; >> � � set &ds; >> � � %do i=1 %to &no; >> � � � if &var = "&&v&i" then output out&i; >> � � � � � � /* if it is numeric, without quotes, or add another >> � � � � � � � parameter for the type and add a bit of macro logic */ >> � � %end; >> � run; >> %mend; >> %split(ds=big,var=split_var); >> >> (don't know if that works...) >> >> Gerhard >> >> >> >> >> >> On Fri, 6 Nov 2009 14:27:51 +0000, Murphy Choy <gola...@GMAIL.COM> wrote: >> >Hi nicky, >> >> >For this type of sampling, please refer to the proc surveyselect >> documentations. >> >> >------Original Message------ >> >From: nickyli >> >Sender: SAS(r) Discussion >> >To: SA...@LISTSERV.UGA.EDU >> >ReplyTo: nickyli >> >Subject: how to split data set >> >Sent: Nov 6, 2009 10:21 PM >> >> >hi, >> > � how to get several data set according to split a big data set by a >> >variable?can it realize by using macro? >> > � thanks a lot >> >> >Sent from my BlackBerry Wireless Handheld >> >> >-- >> >Regards, >> >Murphy Choy >> >> >Certified Advanced Programmer for SAS V9 >> >Certified Basic Programmer for SAS V9- 隐藏被引用文字 - >> >> - 显示引用的文字 - > >as like i have a big data set qttndist,and it had a variable stkcd.the >question is that split the qttndist to sevaral small data sets >according to stkcd. >thanks


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