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 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 12 Jun 2002 12:32:17 -0400
Reply-To:     "Huang, Ya" <ya.huang@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, Ya" <ya.huang@PFIZER.COM>
Subject:      Re: Creating Subsets of Data Based on Variable Values
Comments: To: "Thomas.Hauge@EDDIEBAUER.COM" <Thomas.Hauge@EDDIEBAUER.COM>
Content-Type: text/plain

This question was asked last year, and here is what I will do:

data xx; input v1 v2 v3 v4; cards; 1 2 139 3 4 5 139 6 7 8 65 9 10 11 141 12 ;

proc sql noprint; select distinct 'c'||trim(left(put(v3,best.))) into :dslst separated by ' ' from xx; select distinct "when ("||trim(left(put(v3,best.)))||") output c"||trim(left(put(v3,best.)))||";" into :wlst separated by ' ' from xx;

options symbolgen;

data &dslst; set xx; select (v3); &wlst otherwise; end; run;

------------------- 374 data &dslst; 375 set xx; 376 select (v3); 377 &wlst SYMBOLGEN: Macro variable WLST resolves to when (139) output c139; when (141) output c141; when (65) output c65; 378 otherwise; 379 end; 380 run;

NOTE: There were 4 observations read from the data set WORK.XX. NOTE: The data set WORK.C139 has 2 observations and 4 variables. NOTE: The data set WORK.C141 has 1 observations and 4 variables. NOTE: The data set WORK.C65 has 1 observations and 4 variables. NOTE: DATA statement used: real time 0.02 seconds cpu time 0.02 seconds

Kind regards,

Ya Huang -----Original Message----- From: Thomas Hauge [mailto:Thomas.Hauge@EDDIEBAUER.COM] Sent: Wednesday, June 12, 2002 9:04 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Creating Subsets of Data Based on Variable Values

Hello everyone,

I am having a difficult time getting my head wrapped around this problem.... I would like to create multiple smaller datasets from one large dataset, based upon the varying values of one of the variables in the large dataset. The new, smaller datasets would contain records with a constant value for that variable, and the names would be based on the values of the variable as well. So, for instance:

Large dataset:

var1 var2 var3 var4 ... ... 139 ... ... ... 139 ... ... ... 65 ... ... ... 141 ...

would result in smaller datasets named:

C139.ssd01 (i.e. only records where var3=139) C65.ssd01 C141.ssd01

The catch is, I would like to automate this since this will be an ongoing process, and the number of different variable values also varies (probably only between 2 and 10 different values, but who knows...)

This would be on UNIX using version 6.12.

Any help would be appreciated,

Thomas Hauge Eddie Bauer Marketing


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