BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

 

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?

 

5 REPLIES 5
Q1983
Lapis Lazuli | Level 10
WARNING: The ID value "_K11" occurs twice in the same BY group.
Yes I do get that message.
So is there a way to show the 7/26/19 K11 entry also
ln _K11 _K11 _K12 _A13 _B9 _B10
0013 26Jul2019 29Jul2019 30Jul2019
0033 31Aug2019
0034 01Aug2019 02Aug2019
data_null__
Jade | Level 19

To save time show example of your desired output.

Q1983
Lapis Lazuli | Level 10

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

Tom
Super User Tom
Super User

@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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 553 views
  • 0 likes
  • 4 in conversation