Date: Tue, 28 Dec 1999 16:17:31 GMT
Reply-To: Grzegorz Tabor <tabor@SAWAN.COM.PL>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Grzegorz Tabor <tabor@SAWAN.COM.PL>
Organization: TPNET - http://www.tpnet.pl
Subject: Re: Antwort: A data step question
Content-Type: text/plain; charset=iso-8859-2
data human;
length gender $1;
set man (in=a) woman;
if (a) then
gender = 'M';
else
gender = 'F';
run;
automatic variable 'a' is set to 1 when SAS is processing the
first incomming data set.
Gehard Hellriegel wrote:
>
> Hi Friends,
>
> Suppose I have two datasets: MAN (observations of man), WOMAN (obs of
> woman)
> Both datasets have 2 variables: NAME, AGE
>
> Now I would like to have a single dataset HUMAN
>
> DATA HUMAN;
> SET MAN WOMAN;
>
> But I want to have an additional variable GENDER. So that All MAN obs
> should have GENDER=M. All WOMAN obs should have =F.
>
> I know a stupid way is
>
> DATA MAN;
> SET MAN;
> GENDER='M';
>
> DATA WOMAN;
> SET WOMAN;
> GENDER='F';
>
> Can you teach a clever syntax to do this ?
>
> Thanks in advance.
> cp
>
> try the following:
>
> DATA HUMAN;
> SET MAN (in=male) WOMAN;
> if male then gender="M"; else gender="F";
>
> Mit freundlichen Grüßen
>
> Gerhard Hellriegel, DeTeCSM
>
> WestLB
> Abteilung: 001-80622
> Aderstr. 22
> D - 40217 Duesseldorf
> Tel.: +49211 826 6173
> Fax: +49211 826 5393
|