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