Date: Mon, 12 Feb 1996 10:40:52 -0500
Reply-To: Phil Gallagher <pgallagh@MAIL.CATO.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Phil Gallagher <pgallagh@MAIL.CATO.COM>
Organization: Cato Research Ltd.
Subject: another way to "merge" datasets
In-Reply-To: <EFBA1B5102D2B4D1>
If one is not comfortable with the perfectly respectable method of
merging a one-observation, one variable dataset onto another dataset that
was recently given in response to the query posed by Jim Stansell, that
is,
data tempfile;
set temp2;
if _n_=1 then set temp1;
run;
then you may like the CALL SYMPUT method of skinning the same poor cat
better. At first blush I think it is not worse programming style than
the "if _n_ ..."; note, however, that the "if _n_ ..." method has the
distinct advantage of being in the Friendly Manual, and is therefore much
easier to access again when one needs the same function again but the
brain refuses to remember.
Phil Gallagher
* expt to try the macro method of "merging" a single valued variable
onto a file;
DATA ONE;
X = 5;
CALL SYMPUT('ADD_ON', PUT(X,BEST8.));
RUN;
* first, the "MERGE" look-alike;
DATA DEFICIEN;
INPUT A B;
CARDS;
5 3
4 6
7 8
;
RUN;
DATA SUFFICIE;
SET DEFICIEN;
C = &ADD_ON;
RUN;
PROC PRINT; TITLE 'Dataset SUFFICIE'; RUN; TITLE;
* second, the one-step way that _really_ doesn't look like a MERGE;
DATA SUFFICI2;
INPUT D E;
C = &ADD_ON;
CARDS;
5 3
4 6
7 8
;
PROC PRINT; TITLE 'Dataset SUFFICI2'; RUN; TITLE;