Date: Mon, 8 Apr 1996 15:00:01 PDT
Reply-To: TWB2%Rates%FAR@GO50.COMP.PGE.COM
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: TWB2%Rates%FAR@GO50.COMP.PGE.COM
Subject: Re: macro to create data sets
If I were actually doing this work, I would not use a macro (see below). Here
is a macro:
%macro make12;
DATA %do ds=1 %to 12;
M&ds
%end;
SET SAMPLE;
%do ds=1 %to 12;
%let prev=%eval(&ds-1);
* Note no ELSE--each ob can be written to all datasets;
IF RESP&ds EQ 1
AND RESP&prev EQ 1
THEN OUTPUT M&ds;
%end;
RUN;
If I actually wanted to do this, I would just type the line
IF RESP0 EQ 1 AND RESP1 EQ 1 THEN OUTPUT M1;, repeat it 11 times and change
the numbers. I feel the macro is too complex for the savings it provides. I
used to feel differently--it is a matter of taste and local custom.
Tim Berryhill - Contract Programmer and General Wizard
TWB2@PGE.COM or http://www.lookup.com/Homepages/92062/home.html
Frequently at Pacific Gas & Electric Co., San Francisco
The correlation coefficient between their views and
my postings is slightly less than 0
----------------------[Reply - Original Message]----------------------
Sent by:Kratzke_D <KratzkeD@OEUS.PSB.BLS.GOV>
I'd like to write a macro to create 12 data sets: m1-m12. I have variables
resp0-resp12. The 1st data set is created by:
DATA M1;
SET SAMPLE;
IF RESP1=1 AND RESP0=1;
The 2nd data set is created if resp2=1 and resp1=1, the 3rd one is created
if resp3=1 and resp2=1.