DATA Step, Macro, Functions and more

Proc summary or proc tabulate question

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

Proc summary or proc tabulate question

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

 


Accepted Solutions
Solution
‎04-01-2016 10:52 AM
Super User
Posts: 10,048

Re: Proc summary or proc tabulate question

Posted in reply to Astounding
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


All Replies
Super User
Posts: 5,518

Re: Proc summary or proc tabulate question

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?

Solution
‎04-01-2016 10:52 AM
Super User
Posts: 10,048

Re: Proc summary or proc tabulate question

Posted in reply to Astounding
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;




Contributor
Posts: 38

Re: Proc summary or proc tabulate question

Thanks to everybody.

 

Xia's approach worked well.

 

Thanks Xia,

 

Mirisa

PROC Star
Posts: 1,760

Re: Proc summary or proc tabulate question

This?

proc sort nodupkey;

 by Ltr_ID Date Sce_ID  Stgy_ID ;

run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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