BookmarkSubscribeRSS Feed
gyambqt
Obsidian | Level 7

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

8 REPLIES 8
gyambqt
Obsidian | Level 7

Hi Kurt,

There is no error in the log.

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

Kurt_Bremser
Super User

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.

ven
Calcite | Level 5 ven
Calcite | Level 5

It worked if you use as below

where Sex="M";

gyambqt
Obsidian | Level 7

I think you are right...

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Kurt_Bremser
Super User

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.

gyambqt
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2400 views
  • 0 likes
  • 4 in conversation