BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
8 REPLIES 8
Cynthia_sas
SAS Super FREQ
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]
ballardw
Super 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.
Ksharp
Super 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
ArtC
Rhodochrosite | Level 12
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.
Ksharp
Super User
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
ArtC
Rhodochrosite | Level 12
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.....
Tim_SAS
Barite | Level 11
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.
Ksharp
Super User
Hi.
Unfortunately My SAS 9.2 can not work.
It looks like I need the current version of SAS.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 871 views
  • 0 likes
  • 6 in conversation