Hello,
I would like to transpose a table.
I only want one the same value in ID.
Thanks a lot for your help.
TABLE | ||||||
ID | CODE | DATE | ||||
01 | FAZ58 | 07/01/2020 | ||||
01 | FZE78 | 04/01/2020 | ||||
02 | DS52 | 05/01/2020 | ||||
02 | YU89 | 04/01/2020 | ||||
02 | LM69 | 04/01/2020 | ||||
03 | DS24 | 05/01/2020 | ||||
04 | FS24 | 06/01/2020 | ||||
04 | XC89 | 07/01/2020 | ||||
WANT: | ||||||
ID | CODE1 | DATE1 | CODE2 | DATE2 | CODE3 | DATE3 |
01 | FAZ58 | 07/01/2020 | FZE78 | 04/01/2020 | ||
02 | DS52 | 05/01/2020 | YU89 | 04/01/2020 | LM69 | 04/01/2020 |
03 | DS24 | 05/01/2020 | ||||
04 | FS24 | 06/01/2020 | XC89 | 07/01/2020 |
data have;
input ID $ CODE $ DATE :ddmmyy10.;
format date ddmmyy10.;
cards;
01 FAZ58 07/01/2020
01 FZE78 04/01/2020
02 DS52 05/01/2020
02 YU89 04/01/2020
02 LM69 04/01/2020
03 DS24 05/01/2020
04 FS24 06/01/2020
04 XC89 07/01/2020
;
proc sql noprint;
select max(obs) into :obs
from ( select count(*) as obs from have group by id ) ;
quit;
proc summary nway data=have missing;
class id ;
output out = want(drop=_type_ _freq_)
idgroup(out[&obs](code date)=);
run;
Why do you want to do this? 🙂
data have;
input ID $ CODE $ DATE :ddmmyy10.;
format date ddmmyy10.;
cards;
01 FAZ58 07/01/2020
01 FZE78 04/01/2020
02 DS52 05/01/2020
02 YU89 04/01/2020
02 LM69 04/01/2020
03 DS24 05/01/2020
04 FS24 06/01/2020
04 XC89 07/01/2020
;
proc sql noprint;
select max(obs) into :obs
from ( select count(*) as obs from have group by id ) ;
quit;
proc summary nway data=have missing;
class id ;
output out = want(drop=_type_ _freq_)
idgroup(out[&obs](code date)=);
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: