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 (January 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 1 Jan 2005 12:18:08 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: proc transpose ids in multiple columns
Comments: To: Joan Ab <joanab1970@YAHOO.COM>

Joan,

As Richard already pointed out, there are a lot of ways one can use SAS to accomplish what you are trying to do.

The following is similar to Richard's suggestion, but uses a file to obtain the lookup values:

*read in lookup table; data one; input target_id target_percentage; cards; 001 .10 002 .20 003 .30 ; run;

*get number of records in lookup table; data _null_; if 0 then set one nobs=nobs; CALL SYMPUT('NUMREC',nobs); stop; run;

*read in data file and create a variable showing record number; data two; input type_target_percentage1 type_target_percentage2 type_target_percentage3; numrec=_n_; cards; 001 002 . . . 003 001 002 003 ; run;

*transpose the data file; proc transpose data=two out=three; by numrec; run;

*put the lookup table into an array, then read the transposed data (using the file's values to perform the lookup) and, finally, output the desired records; data four (keep=target_id target_percentage); array t_percentage(&numrec) 3.; do until (eof1); set one end=eof1; t_percentage(target_id)=target_percentage; end; do until (eof2); set three end=eof2; if col1 ne . then do; target_id=col1; target_percentage=t_percentage(target_id); end; else do; target_id=.; target_percentage=.; end; output; end; run;

Art --------- On Fri, 31 Dec 2004 16:53:02 -0800, Joan A <joanab1970@YAHOO.COM> wrote:

>Hello, > >I have two data sets: 1)a lookup dataset and 2) a dataset with ids in multiple columns. > >I wanted to use transpose to put create a new variable from (type_target_percentage3, type_target_percentage3, type_target_percentage3) >


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