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 |
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 1A3456 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
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
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 1A3456 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
Thank you @Reeza .. That worked.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.