data have;
infile datalines ;
input ln $ Date1 Date9. code $ ;
format date1 date9.;
datalines ;
0013 26Jul2019 K11
0013 29Jul2019 K11
0013 29Jul2019 K12
0013 30Jul2019 K12
0033 30Jul2019 A13
0033 31Aug2019 A13
0034 1Aug2019 B9
0034 2Aug2019 B10
;run;
proc sort data=have nodupkey;by ln date1;run;
proc transpose data=have out=have2 (drop= _NAME_ _LABEL_) prefix=_ let ;
id code;
by ln ;
var date1;
run;
Notice that 0013 29Jul2019 K11 shows up but not 0013 26Jul2019 K11. I know we are transposing based on code, ln and date1 however is there a way to show all instances side by side?
You should get a message that K11 appears twice in group 0013. Please show us an example of the expected output.
To save time show example of your desired output.
Desired output
| ln | _K11 | _K11 | _K12 | _A13 | _B9 | _B10 |
| 0013 | 26Jul2019 | 29Jul2019 | 30Jul2019 | |||
| 0033 | 31Aug2019 | |||||
| 0034 | 01Aug2019 | 02Aug2019 |
So I also want to show the first instance of _K11 that occurred on 7/26/19
@Q1983 wrote:
Desired output
ln _K11 _K11 _K12 _A13 _B9 _B10 0013 26Jul2019 29Jul2019 30Jul2019 0033 31Aug2019 0034 01Aug2019 02Aug2019 So I also want to show the first instance of _K11 that occurred on 7/26/19
And what variable name do you propose for this second copy of _K11 ?
Are you sure you don't want a report instead of a dataset?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.