LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Jun 2000 14:42:57 +0200
Reply-To:     Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:      Re: create an indicator
Comments: To: xihu lu <xihulu@YAHOO.COM>
Content-Type: text/plain

Xihu,

A tested data step solution is:

OPTIONS LS=80;

DATA TEST; INFILE CARDS; INPUT ID V1 ; CARDS; 1 1 1 1 1 2 2 1 2 1 3 1 3 2 3 3 4 1 4 1 5 2 5 2 5 2 ; RUN;

PROC SUMMARY DATA=Test; * Possibly option MISSING; CLASS ID; VAR V1; OUTPUT OUT=TestMax MAX=MaxV1;

Title 'TestMax'; PROC PRINT DATA=TestMax; RUN;

DATA Merged; MERGE Test TestMax; BY Id; IF (_TYPE_ EQ 1); RUN;

Title 'Merged'; PROC PRINT DATA=Merged; RUN;

Another solution could make use of PROC TRANSPOSE instead of PROC SUMMARY, BY ID, use the MAX function and merge likewise. I'll leave that to you if wanted.

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer does not need me at all, but I can't do without it anymore.

> -----Original Message----- > From: xihu lu [SMTP:xihulu@YAHOO.COM] > Sent: Sunday, June 25, 2000 11:26 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: create an indicator > > Hello, > > I wonder if someone could help me out with my problem. > > I have a dataset: > > DATA TEST; > INFILE CARDS; > INPUT ID V1 ; > CARDS; > 1 1 > 1 1 > 1 2 > 2 1 > 2 1 > 3 1 > 3 2 > 3 3 > 4 1 > 4 1 > 5 2 > 5 2 > 5 2 > ; > RUN; > > Now I want to create a V1 indicator. If V1 is all '1's > for an id, V1 indicator would be '1'; if V1 has > several > values for an id, and the max value would be the V1 > indicator. So Id 3's V1 indicator is 3. So the result > would > look like: > > id V1 group > > 1 1 2 > 1 1 2 > 1 2 2 > 2 1 1 > 2 1 1 > 3 1 3 > 3 2 3 > 3 3 3 > 4 1 1 > 4 1 1 > 5 2 2 > 5 2 2 > 5 2 2 > > > I wonder how can I achieve this. Many thanks in > advance! > > Please reply to my address as I am not on the mailing > list. > > > Xihu > > > __________________________________________________ > Do You Yahoo!? > Get Yahoo! Mail - Free email you can access from anywhere! > http://mail.yahoo.com/


Back to: Top of message | Previous page | Main SAS-L page