Date: Mon, 9 Apr 2012 13:40:48 -0700
Reply-To: Mike Temp <firstname.lastname@example.org>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Temp <mwc500s@YAHOO.COM>
Content-Type: text/plain; charset=iso-8859-1
I'm trying to use SQL to create a list of macro variables that can then be used in an IF/THEN statement.
This is a large panel dateset where each observation represents a firm and quarter. Each firm has an id, but this might have changed over time. When it changes, the prior id is recorded as pid. The goal is to create a new id that is the same over the entire time frame. My code is below.
When I run this code, the &&a&i and &&b&i will not resolve. I've seen a number of papers that discuss using SQL and macros this way, but not with an IF/THEN statement. I'd appreciate any insight into why this will not execute properly.
into:b1 - :b29866frompred;
%macrop; %doi=1%to29866; if id=&&a&i then id2=&&b&i; %end;%mend
run;;sqlnoprint;selectpidsqlnoprint;selectidinto:a1 - :a29866frompred;