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 (October 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 15 Oct 2004 07:24:49 -0400
Reply-To:     Chetan Saluja <chetan.saluja@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chetan Saluja <chetan.saluja@GMAIL.COM>
Subject:      Passing Arrays

Hi All,

I'm stuck in this peculiar position in which i need to pass an array from one data step to another within the same macro. Now this is what I want.

There is a data set (say test1) containing the following data :- clnt_id | Name --------------- 1 | John 2 | Mary 3 | Augustine 7 | Mark 4 | Wavell 1 | Jack 3 | Kate 2 | Larry

Now I want to split the dataset on the basis on client_id and and the same time name the dataset by the client_id, and each dataset should have only client_id specific data. i.e. we will have

datasets clnt_1 (having) : 1 John 1 Jack clnt_2 (having) : 2 Mary 2 Larry clnt_3 (having) : 3 Augustine 3 Kate clnt_4 (having) : 4 Wavell clnt_7 (having) : 7 Mark.

The most important thing in this program is that it should be generic i.e. it shud accept parameters such that for however big dataset it shud be able to divide.

Now the solution i'm trying:-

%let i=0; %global a =; --------------------------------------------------------------------------- %macro divide_datasets;

proc sql; select count(distinct clnt_id) into :temp from test1; run;

proc sql; create table distinct_clntid as( select distinct clnt_id from test1); run;

data _NULL_; array valu(&temp) _TEMPORARY_; do i=1 to &temp; set distinct_clntid(keep=clnt_id) ; valu(i) = clnt_id; end; run; %do i=1 %to &temp; a = &valu(&i); /*Now this is creating a problem as i'm unable to pass */ /*the value */ data clnt_&a; set test1(where=(clnt_id=&a)); %end; %mend; --------------------------------------------------------------------------- %divide_datasets;


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