BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dunga
Obsidian | Level 7

Hi SAS Forum,

 

I have the below dataset.

 

data have;

input Acct_num date Ltr_ID $ 12-14 Sce_ID Stgy_ID;

cards;

111 201412 TLL 102 603

111 201508 TLL 101 603

222 201404 JJJ 83 245

222 201508 JJJ 83 300

;

run;

 

Question:

Using the above data set (over 50k records), I wanted to create the below table. Below table simply presents what are the Dates, Sce_IDs and Stgy_IDs associated with each Ltr_ID.

 

Ltr_IDDateSce_ID Stgy_ID
TLL201412102603
 201508101 
JJJ20140483245
 201508 300

 

Could you please help me. I have used cross tabs and proc frequencies etc but found difficult. I am using sas ver 9.3.

Thanks

Mirisa

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
input Acct_num date Ltr_ID $ 12-14 Sce_ID Stgy_ID;
cards;
111 201412 TLL 102 603
111 201508 TLL 101 603
222 201404 JJJ 83 245
222 201508 JJJ 83 300
;
run;
 
 data want;
  set have;
 if Acct_num = lag(Acct_num) then call missing(Acct_num );
  if Ltr_ID = lag(Ltr_ID ) then call missing(Ltr_ID );
 if Sce_ID = lag(Sce_ID ) then call missing(Sce_ID );
 if Stgy_ID= lag(Stgy_ID) then call missing(Stgy_ID);
run;




View solution in original post

4 REPLIES 4
Astounding
PROC Star

This appears to be a job for PROC PRINT, and not a summary procedure.  Are there any cases where you don't want to print every observation?

Ksharp
Super User
data have;
input Acct_num date Ltr_ID $ 12-14 Sce_ID Stgy_ID;
cards;
111 201412 TLL 102 603
111 201508 TLL 101 603
222 201404 JJJ 83 245
222 201508 JJJ 83 300
;
run;
 
 data want;
  set have;
 if Acct_num = lag(Acct_num) then call missing(Acct_num );
  if Ltr_ID = lag(Ltr_ID ) then call missing(Ltr_ID );
 if Sce_ID = lag(Sce_ID ) then call missing(Sce_ID );
 if Stgy_ID= lag(Stgy_ID) then call missing(Stgy_ID);
run;




dunga
Obsidian | Level 7

Thanks to everybody.

 

Xia's approach worked well.

 

Thanks Xia,

 

Mirisa

ChrisNZ
Tourmaline | Level 20

This?

proc sort nodupkey;

 by Ltr_ID Date Sce_ID  Stgy_ID ;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 896 views
  • 0 likes
  • 4 in conversation