The SAS Output Delivery System and reporting techniques

need report for 40 variables and 20 observations

Reply
N/A
Posts: 0

need report for 40 variables and 20 observations

Hello if anyone know the solution please reply me

i have a data set with around 40 variables and 20 observarions
i need to produce a report for that in the below mentioned way

1.each observation in a page i.e 20 observations in 20 pages

2.one obervation has only 18 variables and the data and in the remaining 2 variables s missing.

report for this observation should have only 18 variables and the variables with missing data must be removed.

for this program with proc report i need to give all the 40 variable names in the column statement.

is there any other way to solve this without giving the 40 variable names
since i have many data sets with different variable names


Thanks
Sid
SAS Super FREQ
Posts: 8,868

Re: need report for 40 variables and 20 observations

Posted in reply to deleted_user
Hi:
Aside from other issues, SAS would want every "page" to contain all the same observations. So if you look at the output from this program, you will see that there is a column for HEIGHT and WEIGHT for every observation (there are only 3 observations) -- for the observation for Barbara, the values for HEIGHT and WEIGHT are shown as missing.

Unless you did a LOT more processing, this is the way that most SAS procedures will behave by default. BTW, you can see that in the code below, I do NOT need to list all the variable names in the COLUMN statement (the only reason to list the variables in the COLUMN statement is if you need for the variables to be in a particular order from left to right on the report row).

cynthia
[pre]
data makedata;
set sashelp.class(obs=3);
if _n_ = 3 then do;
height=.;
weight=.;
end;
run;

ods html file='c:\temp\showdata.html' style=sasweb;
proc report data=makedata nowd;
title 'Cannot "remove" variables for height and weight for Barbara obs';
column _character_ _numeric_;
define name / order;
break after name / page;
run;
ods html close;
[/pre]
Super User
Posts: 11,343

Re: need report for 40 variables and 20 observations

Posted in reply to deleted_user
I'm not sure it this will completely suit your purpose but here is one approach.

A small example data set.
data junk;
infile datalines truncover;
input v1-v5 ;
label
v1 = 'Label 1'
v2 = 'Label 2'
v3 = 'Label 3'
v4 = 'Label 4'
v5 = 'Label 5'
;
datalines;
1 2 3 4 5
6 7 8 9 10
11 12 13
;
run;

Manually transpose the data creating a page variable and using the labels of the individual variables to conditionally create a categorical variable for non-missing values.

data junk2 (keep=page label value);
set junk;
array v v1-v5;
do i= 1 to dim (v);
page= _n_;
if v ne . then do;
label= vlabel(v);
value= v;
output;
end;
end;
run;

This will provide a single class or group variable, LABEL in this case with the values in an analysis varible and PAGE something to provide a break on changing values.
Super User
Posts: 10,044

Re: need report for 40 variables and 20 observations

Posted in reply to deleted_user
Hi. There is an option in proc report 'nozero' can do it.
But it only work for listing destination.
Maybe you can save the output of listing destination to txt file or something else.

[pre]
data makedata;
set sashelp.class(obs=3);
if _n_ = 3 then do;
height=.;
weight=.;
end;
run;


proc report data=makedata nowd;
title 'Cannot "remove" variables for height and weight for Barbara obs';
column _character_ _numeric_;
define name / group;
define height/ display nozero;
define weight/display nozero;
break after name / page;
run;


[/pre]


Ksharp
Valued Guide
Posts: 634

Re: need report for 40 variables and 20 observations

The NOZERO is a good possibility Ksharp. Further testing should show that the NOZERO option will work for the PDF, RTF, and HTML destinations as well. The option is used on the DEFINE statement and will remove a column if all values in the table are missing or 0 (zero). In this case with the PAGE option on the BREAK AFTER statement the table is the page.
Super User
Posts: 10,044

Re: need report for 40 variables and 20 observations

Hi.ArtC
I guess your sas version is before 9.2.So 'nozero' is worked for PDF RTF.....
Unfortunately, After SAS9.2 'nozero' is only supported for listing destination.


Ksharp
Valued Guide
Posts: 634

Re: need report for 40 variables and 20 observations

Well I know that is what the documentation says, and I cannot speak for other SAS installations, but at least NOZERO works for my version of SAS9.2 under windows xp for HTML, PDF, and RTF. Of course that too may get fixed in the future, but for now.....
Super Contributor
Posts: 394

Re: need report for 40 variables and 20 observations

The NOZERO option was broken for a short period early in 9.2. However it is present and working for all ODS destinations in the current release.
Super User
Posts: 10,044

Re: need report for 40 variables and 20 observations

Hi.
Unfortunately My SAS 9.2 can not work.
It looks like I need the current version of SAS.
Ask a Question
Discussion stats
  • 8 replies
  • 226 views
  • 0 likes
  • 6 in conversation