The SAS Output Delivery System and reporting techniques

Display all variables in a zero data set

Reply
N/A
Posts: 0

Display all variables in a zero data set

This might sound weird. I am subsetting a data set to proc report it, after subsetting, the resulting data set has zero observation,so only the column headings are dispalyed but not the rows below them. For reporting purpose i need the other columns to be displayed, eventhough the corresponding values to those rows dont exist.

For eg. after subsetting i want the table to be displayed as below

plan para criteria value1 value2

A XXX YYYY . .

B XXX YYYY . .

I am using data step not SQL.

Thanks
SAS Super FREQ
Posts: 8,864

Re: Display all variables in a zero data set

Posted in reply to deleted_user
Hi:
I'm confused -- you're using the DATA step and not PROC SQL for the subset??? What do you mean by "other columns"??? If PLAN, PARA, CRITERIA, VALUE1 and VALUE2 are the column headers, then what are the values A, B, XXX and YYYY -- are those COLUMN NAMES or COLUMN VALUES????

I don't understand how you are even seeing column headers. When I run this PROC REPORT and ask for a subset with 0 observations, nothing is displayed at all -- not even headers:
[pre]
2552 ods listing;
2553 ods html file='c:\what_is_report.html' style=sasweb;
NOTE: Writing HTML Body file: c:\what_is_report.html
2554 proc report data=sashelp.class nowd;
2555 where age = 17;
2556 run;

NOTE: No observations were selected from data set SASHELP.CLASS.
NOTE: No observations in input data set.
NOTE: There were 0 observations read from the data set SASHELP.CLASS.
WHERE age=17;
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

2557 ods html close;
[/pre]

And, even if I use a DATA step to do the subset, I still do not get any report -- only the following messages about 0 observations:
[pre]
2567 data newclass;
2568 set sashelp.class;
2569 where age = 17;
2570 run;

NOTE: There were 0 observations read from the data set SASHELP.CLASS.
WHERE age=17;
NOTE: The data set WORK.NEWCLASS has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds

2571
2572 ods listing;
2573 ods html file='c:\what_is_report2.html' style=sasweb;
NOTE: Writing HTML Body file: c:\what_is_report2.html
2574 proc report data=newclass nowd;
2575 run;

NOTE: No observations in data set WORK.NEWCLASS.
NOTE: No observations in input data set.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

2576 ods html close;
[/pre]

There are no observations with AGE=17 in SASHELP.CLASS. It would help if you showed your complete code and/or your code in the SAS log (with messages).

cynthia
N/A
Posts: 0

Re: Display all variables in a zero data set

Posted in reply to Cynthia_sas
What you are saying is right. I dont see any observations or coulmn heading displayed if i just run the program. When i go into explorer window and try to open the sas table at that point i can see the column headings.

what are the values A, B, XXX and YYYY -- are those COLUMN NAMES or COLUMN VALUES????

They are values.

Any way i want the no observation table to be displayed for reporting purpose, to show that their are no observation.
SAS Super FREQ
Posts: 8,864

Re: Display all variables in a zero data set

Posted in reply to deleted_user
Hi:
You might want to search the previous forum postings or do a Google search -- this question has come up a lot. As you have discovered, there's no SAS procedure that will "automatically" give you a report with 0 rows.

So, you will have to use one of the previously posted solutions. Most folks just want to display a message that there were 0 observations. If you want to display an "empty" dataset with column headers and missing values for all the variables, then you will probably have to make such a dataset using programming techniques.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 340 views
  • 0 likes
  • 2 in conversation