Date: Fri, 16 May 2008 13:19:50 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: Nested Data Accesses?
Content-Type: text/plain; charset=iso-8859-1
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On
> Behalf Of Laptop765@GMAIL.COM
> Sent: Friday, May 16, 2008 1:09 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Nested Data Accesses?
> Hello. I'm relatively new to SAS but have a pretty good understanding
> of it. I am having difficulty with something... I have:
> data temp;
> set olddata;
> getnum is a macro whose contents are a proc sql to grab the values
> that I need to use to update temp. SAS claims that var1 and var2 are
> invalid statements or out of place (error 180-322). After much
> debugging I discovered that if I remove the call to getnum, it works
> fine (although I do not have my val1 and val2). This seems to
> indicate that a proc sql nested inside a data step is not allowed...
That is correct. You cannot nest proc sql (or another data step) inside a data step.
> Essentially what I need to do is update some data with values
> calculated based on existing data in a different set. Is this even
> possible? If so, does anybody have any suggestions on how to go about
> doing it?
Yes it is possible. How you do it will depend on how your files are structured, what calculations your need to do, and probably some other considerations. Doing it all in proc sql may be possible, or using a merge, or hash may work.
Can you tell us a little more about what your files look like and the calculations that you need to do? What does your %getnum macro look like / do?
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204