```Date: Sat, 1 Jan 2005 12:18:08 -0500 Reply-To: Arthur Tabachneck Sender: "SAS(r) Discussion" From: Arthur Tabachneck Subject: Re: proc transpose ids in multiple columns Comments: To: Joan Ab 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 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