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

Hi, 

Please consider the below test dataset 

data test;
input ENUMBER $ DESCRIPTION $ LINKED_ENUM $ SET;
datalines;
A1234 SECTION1 B345 1
A1234 SECTION1 B346 1
A2345 SECTION2 B678 1
A2345 SECTION2 B789 1

A3456 SECTION3 B12 2
A3456 SECTION3 B23 2
A3456 SECTION3 B78 2
A4536 SECTION4 B233 2
A5467 SECTION5 B322 2
A5467 SECTION5 B566 2
run;

 

I wish to run a proc report to get the output as below. The repeated values of ENUMBER and description should not be printed and the order needs to be maintained.

I understand one way to do it would be to amend my dataset by using the FIRST.variable indicator variables and then run a proc report. 

But is there a way to do it in proc report without doing anything to the underlying dataset.  

 

ENUMBERDESCRIPTIONLINKED_ENUMSET
A1234SECTION1B3451
  B3461
A2345SECTION2B6781
  B7891
A3456SECTION3B122
  B232
  B782
A4536SECTION4B2332
A5467SECTION5B3222
  B5662

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I believe that's the default behavior when you specify it as a GROUP variable.

 

proc report data=test nowd;
columns enumber description linked_enum set;
define enumber / group;
define description / group;
define linked_enum / display;
define set / display;
run;

@Anuz wrote:

Hi, 

Please consider the below test dataset 

data test;
input ENUMBER $ DESCRIPTION $ LINKED_ENUM $ SET;
datalines;
A1234 SECTION1 B345 1
A1234 SECTION1 B346 1
A2345 SECTION2 B678 1
A2345 SECTION2 B789 1

A3456 SECTION3 B12 2
A3456 SECTION3 B23 2
A3456 SECTION3 B78 2
A4536 SECTION4 B233 2
A5467 SECTION5 B322 2
A5467 SECTION5 B566 2
run;

 

I wish to run a proc report to get the output as below. The repeated values of ENUMBER and description should not be printed and the order needs to be maintained.

I understand one way to do it would be to amend my dataset by using the FIRST.variable indicator variables and then run a proc report. 

But is there a way to do it in proc report without doing anything to the underlying dataset.  

 

ENUMBER DESCRIPTION LINKED_ENUM SET
A1234 SECTION1 B345 1
    B346 1
A2345 SECTION2 B678 1
    B789 1
A3456 SECTION3 B12 2
    B23 2
    B78 2
A4536 SECTION4 B233 2
A5467 SECTION5 B322 2
    B566 2

 

 

 

 


 

View solution in original post

3 REPLIES 3
jimbarbour
Meteorite | Level 14

I think the easiest thing to do would be to create a WORK copy of the dataset just containing the records that you actually want displayed and then run the Proc Report.  When you close your SAS session (or when the job ends if you're running a SAS batch job), the WORK copy is automatically deleted, but your original data will not have been altered in any fashion.

 

Jim

Reeza
Super User

I believe that's the default behavior when you specify it as a GROUP variable.

 

proc report data=test nowd;
columns enumber description linked_enum set;
define enumber / group;
define description / group;
define linked_enum / display;
define set / display;
run;

@Anuz wrote:

Hi, 

Please consider the below test dataset 

data test;
input ENUMBER $ DESCRIPTION $ LINKED_ENUM $ SET;
datalines;
A1234 SECTION1 B345 1
A1234 SECTION1 B346 1
A2345 SECTION2 B678 1
A2345 SECTION2 B789 1

A3456 SECTION3 B12 2
A3456 SECTION3 B23 2
A3456 SECTION3 B78 2
A4536 SECTION4 B233 2
A5467 SECTION5 B322 2
A5467 SECTION5 B566 2
run;

 

I wish to run a proc report to get the output as below. The repeated values of ENUMBER and description should not be printed and the order needs to be maintained.

I understand one way to do it would be to amend my dataset by using the FIRST.variable indicator variables and then run a proc report. 

But is there a way to do it in proc report without doing anything to the underlying dataset.  

 

ENUMBER DESCRIPTION LINKED_ENUM SET
A1234 SECTION1 B345 1
    B346 1
A2345 SECTION2 B678 1
    B789 1
A3456 SECTION3 B12 2
    B23 2
    B78 2
A4536 SECTION4 B233 2
A5467 SECTION5 B322 2
    B566 2

 

 

 

 


 

Anuz
Quartz | Level 8

Thank you @Reeza .. That worked. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 2601 views
  • 3 likes
  • 3 in conversation