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

In the proc report example below, is there a way to hide or suppress the column where y=4 from the output?

 

data a;

input x 1. y 1.;

datalines;

 

14

24

33

22

;

run;

proc report data=a;

columns x y;

define x / group;

define y / across;

define n / format=8.;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Since you made both Y and Z Across variables and you're getting the count in every cell, it's going to be hard to suppress the Y=4 column when the data is structured the way you show.

 

  If you restructured your data, so that there was only 1 value on every row and a type indicator that was character, that would be easier to suppress the entire column when Y=4, as shown below:

restructure_data_suppress_4.png 

 

If you're OK seeing a column for Y=4, but with missing instead of a count, then you could use a COMPUTE block to change the value to 0 or missing. But the challenge with that is that the Y column would still be there and since Y is an ACROSS variable in your example code, you would have to use an absolute column number in the COMPUTE block.

 

  I just used a datalines for the restructured data to show you how it would work. You could also write a program to restructure what you have into this form. Hope this helps,

 

Cynthia

View solution in original post

8 REPLIES 8
SuryaKiran
Meteorite | Level 14

Use a where condition near data

 

proc report data=a(where=(y<>4));
Thanks,
Suryakiran
Reeza
Super User

proc report data=a;

WHERE y ne 4;

columns x y;

define x / group;

define y / across;

define n / format=8.;

run;

 

Most procs support a WHERE statement. 

 

 

Batman
Quartz | Level 8

Thanks to both respondents.  I should have been clearer, I actually plan to use more variables and would like the observations that contain y=4 to be in those distributions.   The solution you recommended wouldn't allow that.   Is there a way to just hide the column from the output for display purposes?

Reeza
Super User

Provide more details, preferably some more data and an example of what you want as output.

 


@Batman wrote:

Thanks to both respondents.  I should have been clearer, I actually plan to use more variables and would like the observations that contain y=4 to be in those distributions.   The solution you recommended wouldn't allow that.   Is there a way to just hide the column from the output for display purposes?


 

 

Batman
Quartz | Level 8

Here is a better example.   I'd like to hide the column where y=4, but I'd still like all values of z to appear.

 

 

data a;

input x 1. y 1. z 1.;

datalines;

 

146

240

330

220

;

run;

proc report data=a;

columns x y z;

define x / group;

define y / across;

define z / across;

define n / format=8.;

run;

 

Reeza
Super User

Then I would suggest either a computed column that sets it to blank if it's 4, or a custom format that masks it if it's 4. 

 

 

Batman
Quartz | Level 8

Do you have a sample of either?   How can I write a compute block for a value of a variable that is defined as an across variable?

Cynthia_sas
SAS Super FREQ

Hi:

  Since you made both Y and Z Across variables and you're getting the count in every cell, it's going to be hard to suppress the Y=4 column when the data is structured the way you show.

 

  If you restructured your data, so that there was only 1 value on every row and a type indicator that was character, that would be easier to suppress the entire column when Y=4, as shown below:

restructure_data_suppress_4.png 

 

If you're OK seeing a column for Y=4, but with missing instead of a count, then you could use a COMPUTE block to change the value to 0 or missing. But the challenge with that is that the Y column would still be there and since Y is an ACROSS variable in your example code, you would have to use an absolute column number in the COMPUTE block.

 

  I just used a datalines for the restructured data to show you how it would work. You could also write a program to restructure what you have into this form. Hope this helps,

 

Cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 4004 views
  • 2 likes
  • 4 in conversation