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:         Tue, 27 Jun 2000 14:24:17 +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: another question
Comments: To: xihu lu <xihulu@YAHOO.COM>
Content-Type: text/plain

Xihu,

...... and yet another tested and approved solution. This one is based upon the question to the number of different V1's per ID, i.e. the frequency of unique V1 values per ID, or rather the frequency of the frequency of all V1 values for each ID value. The Original and Resulting datasets get sorted BY Id:

OPTIONS LS=80;

DATA Original; 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 SORT DATA=Original OUT=Sorted; BY Id; RUN; * If not sorted already;

PROC FREQ DATA=Original; * Calculate frequency of crossings in cells; TABLES Id*V1 / OUT=CrosTab1 (DROP=PERCENT) NOPRINT; RUN;

PROC FREQ DATA=CrosTab1; * Calculate frequency of Id's, dependent from V1; TABLES Id / OUT=CrosTab2 (DROP=PERCENT) NOPRINT; RUN;

DATA Result; MERGE Sorted CrosTab2 (RENAME=(Count=Source)); BY Id; RUN;

PROC PRINT; RUN;

I hope the remaining code is self-explaining sufficiently.

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: Tuesday, June 27, 2000 12:01 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: another question > > Hi, > > First of all, my gratitude to all those who responded > to my question yesterday about creating an indicator. > Now I have another question I'd like to get your help. > > > Say: > > > 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; > > > I'd like to create a varible, named SOURCE. > Each value in V1 represnts a source. For example, if > V1 has two different values for an id, > source =2; if v1 has all three values, source = 3 > so the result looks like: > > id V1 source > > 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 1 > 5 2 1 > 5 2 1 > > Many thanks for your further assistance. > > 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