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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1747 views
  • 0 likes
  • 4 in conversation