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 (March 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Mar 2009 09:23:36 -0400
Reply-To:     SAS_learner <proccontents@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS_learner <proccontents@GMAIL.COM>
Subject:      Re: Macro
Comments: To: Randy <randistan69@hotmail.com>
In-Reply-To:  <200903151918.n2FAlQ5e015240@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Hello Randy,

As Richard and other spoke it would be easier for us to give you better solution if we know what you are upto any way in the suitations like this I usually adopt this technique. This assumes that you have 1000 Subjects today and tomorrow this might go up or go down right?

I am also assuming that you need to put them back into One dataset after you are done processing so here is some thing I use , Hope this helps

Proc Sort data = <Ur data> Out = Pat_id (Keep = Usubjid ) Nodupkey ; By Usubjid ; Run;

*Assuming Your Macro name is For *; Proc Sql Noprint ; Select ('%for(name='!! name!! ')' ) Into : V_name Separated by " " From Pat_d ; &V_name; Quit ;

*This is to Put the data sets Individually *; Proc Sql Noprint ; Select Distinct (Memname) Into : V_names Separated by " " From Dictionary.Columns where Lowcase(libname) = "work" and lowcase(memname) like 'Out-Put data sets name%'; Quit ; Data large ; Set &V_names.<Individual datasets> ; Run;

On Sun, Mar 15, 2009 at 3:18 PM, Randy <randistan69@hotmail.com> wrote:

> On Sun, 15 Mar 2009 10:52:10 -0500, Joe Matise <snoopy369@GMAIL.COM> > wrote: > > I have the code that works perfectly for one patient. It is becoming > difficult for me to generalize the code to the 1000 patients. It is for > this reason that I want to call up each patient individually, process the > data and then put it together back again. I know that is is inefficient, > but I cannot seem to get the generalized code to work for the 1000 > patients. > Anindya, do I use this macro (start and end) only for the first data > statement where I call up the file of each patient, or does the macro end > after the entire data for one patient is processed, that is, after the last > data statement. > Thanks for everything. > > > >Ahh, too early in the morning for me to completely parse the OP (and read > >the second half) apparently. > > > >Since ./NULL seems to not be reading the list this morning, I'll post > this > >part for him, expanding on the end of Anindya's post: > > > >The correct answer is not how to to this, it's how to do what you really > >want :) > > > >What do you really want to do? I can't imagine anything you might want to > >do that really requires you doing what you say - splitting into separate > >datasets, then doing something, then setting back together. Pretty much > >anything you might do that way would be more efficiently done with the > >single dataset. If you post more details about what type of 'processing' > >you are doing, perhaps we can help design a better solution. > > > >-Joe > > > > > >On Sun, Mar 15, 2009 at 10:38 AM, Anindya Mozumdar < > >anindya.lugbang@gmail.com> wrote: > > > >> %macro processPatient(patientid=); > >> %mend processPatient; > >> > >> %macro processPatients(); > >> > >> %do i = 1 %to 1000; > >> data _null_; > >> set <your dataset> (firstobs = &i obs = &i); > >> call symput('patientid', patientid); > >> run; > >> %processPatient(patientid=&patientid) > >> %end; > >> > >> %mend processPatients; > >> > >> %processPatients() > >> > >> However, I would strongly advise you to check whether some > >> pre-processing can be done for all patients together which can improve > >> the performance of the processPatient macro. > >> > >> Regards, > >> Anindya > >> > >> On Sun, Mar 15, 2009 at 8:46 PM, Randy <randistan69@hotmail.com> wrote: > >> > Dear All: > >> > I have a data set for 1000 patients each with a patient ID from 1 - > >> 1000. > >> > I want to write a Macro which pulls in each patient, the code > processes > >> the > >> > data and then saves it as a file for each individual patient. > >> > > >> > So > >> > data need ; set have; > >> > if patient_ID = '1'/* I want it for patients 1 -1000 */ then output ; > >> > run; > >> > . > >> > . > >> > . > >> > Code > >> > > >> > data patient1 /* From patients 1-1000 */ ; set processed_data; > >> > run; > >> > > >> > Is there a Macro that can be written that pulls in each patient ID and > >> then > >> > saves it as a separate file. > >> > Thanx > >> > > >> > > I have the code that works perfectly for one patient. It is becoming > difficult for me to generalize the code to the 1000 patients. It is for > this reason that I want to call up each patient individually, process the > data and then put it together back again. I know that is is inefficient, > but I cannot seem to get the generalized code to work for the 1000 > patients. > Anindya, do I use this macro (start and end) only for the first data > statement where I call up the file of each patient, or does the macro end > after the entire data for one patient is processed, that is, after the last > data statement. > Thanks for everything. >


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