DATA Step, Macro, Functions and more

ODS problem

Reply
Regular Contributor
Posts: 152

ODS problem

Hello experts,

I tried to run the following program to produce xml output with two tabs in the excel. But it didn't work when I included "where" statement,

ODS LISTING CLOSE;                                                                                                                                                                                      
ODS tagsets.excelxp FILE="c:\example.xls";

ods tagsets.excelxp options(sheet_name="cars");

Proc print data=sashelp.cars;
where origin="Europe";
Run;

ods tagsets.excelxp options(sheet_name="class");

Proc print data=sashelp.class;
where Sex="Male";
Run;

ods tagsets.excelxp close;
ods listing;

Thanks

Super User
Posts: 7,773

Re: ODS problem

What does the log say?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 152

Re: ODS problem

Posted in reply to KurtBremser

Hi Kurt,

There is no error in the log.

The output file produced only contain 1 tab "Cars" whereas the other tab is missing.

Super User
Posts: 7,773

Re: ODS problem

There is a LOT more than just error message(s) to be found in the log. I guess you will find a

NOTE: No observations were selected from data set SASHELP.CLASS.

NOTE: There were 0 observations read from the data set SASHELP.CLASS.

      WHERE 0 /* an obviously FALSE WHERE clause */ ;

message in the log, which will give you a clue that the where condition is the culprit and must be examined in depth.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor ven
Contributor
Posts: 37

Re: ODS problem

It worked if you use as below

where Sex="M";

Regular Contributor
Posts: 152

Re: ODS problem

I think you are right...

Super User
Super User
Posts: 7,942

Re: ODS problem

Yes, good idea to have a look at the dataset.  The string withing quotes needs to match exactly the string within the variable.

Super User
Posts: 7,773

Re: ODS problem

And be aware when inspecting your data that SAS may show you formatted values, while the where condition needs the raw, unformatted values to work.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 152

Re: ODS problem

Posted in reply to KurtBremser

I have double checked the dataset, the value "Male" is not in the dataset SAShelp.class. It uses "M".

Ask a Question
Discussion stats
  • 8 replies
  • 657 views
  • 0 likes
  • 4 in conversation