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;
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:
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
Use a where condition near data
proc report data=a(where=(y<>4));
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.
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?
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?
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;
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.
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?
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:
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
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.
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.