Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Proc Report ACROSS variable question 1

Status
Not open for further replies.

YFC

Programmer
Jan 26, 2007
3
US
Hello,

I am using proc report to create a table showing the relative frequencies of likert variables (scored from 0 to 10) in a sample, where the variables are listed in rows and the categories in columns. So, the table ends up looking something like this:
0 1 2 3 4 5 8 9 10
Var 1 .3 .2 .02 .02 .01 .2 .1 .05 .1
Var 2 .02 .2 .3 .02 .01 .2 .1 .05 .1
.
.
.

I can do this by creating a data set structured as follows:

PersonID VarLabel Score
1 Var1 2
1 Var2 10
2 Var1 4
2 Var2 8
.
.
.

and then use Proc Report, treat "Score" as an ACROSS variable, and VarLabel as a Group Variable.

However, I am running into problems whenever a category variable is missing from the above data set (such as, for example, "5"). In this case the proc report code omits "5" from the column, and since I am using COMPUTE statements to get the relative frequencies , the references to the columns will also have to adjusted depending on the missing categories.

Is there a way to include the missing categories into the table (showing the frequency of zero) when using an ACROSS variable?

Thank you,
FC
 
I believe that Proc Report has a "missing" option.. does that help?
Code:
proc report data=blah missing;
 ...
 ...
run;
I've never actually used ACROSS though.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hi,

Thank you for the tip, unfortunately I tried the "missing" option and what it seeems to do is to include categories with a '.' in the table. If the category itself is missing (say only apples and oranges are in the data set, but I want to show pears in the table too even though the frequency will be zero).

Thank you though, YFC

 
YFC,
I have run into the very same problem that you address here. In fact its so prevelent in my industry that the company I work for wrote a specific routine to handle that case. In short your problem is if the catagory has no data for display SAS 'decides' that it isn't needed. Those guys have no idea what regulators want to see. :)

Anyway the way we handle this is to create a dummy record and set every variable to a value. Than in the proc report you can use the 'where' statement to eliminate the dummy record. The trick is that SAS's report procedure 'sees' the column but at the last minute doesn't have any data to display.
 
Hi,

Thank you for the tip, that does it. Glad to know this was not an arcane problem, perhaps SAS can include an option addressing it later on.

Thanks again,
YFC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top