BookmarkSubscribeRSS Feed
sas_vegas
Calcite | Level 5

I would like to use the ODS tagsets sheet_interval option with a macro variable to create separate sheets for a frequency of each variable within the macro. For example, here I want separate tabs showing the values by year and state for "make," "model," and "color":

%LET varlist = make model color;

ODS tagsets.ExcelXP BODY = "C:\Mypath\myfile.xml";

ODS tagsets.ExcelXP options(sheet_interval='&varlist' absolute_column_width=&COL width_fudge='0.6' embedded_titles='Yes' sheet_name="");

PROC SURVEYFREQ DATA=mydata;
TABLES year*state*(&varlist) / ROW CL; WEIGHT mywgt; RUN; ODS tagsets.ExcelXP CLOSE;

 

Right now, this code gives my a file with a separate tab for every table combination (e.g.one tab for the "make" table where year=2011 and state=alabama; one for the "make" table where year=2011 and state=alaska; etc.). Ideally, it would separate JUST on the macro variables so one "make" tab will have the cross-sections of every make by year and state - three tabs in total. Can someone help me see what I'm doing wrong?

 

Thanks! I'm using SAS 9.4.

2 REPLIES 2
ballardw
Super User

 

 

You are getting a sheet per each table as the default. I might expect you to get a message as '&varlist' doesn't resolve your variables would not be valid options for sheet_interval which can be Table, Page, Bygroup, Proc, and None.

 

If I want to control output in the manner you are suggesting I would suggest sending the desired output to datasets using ODS OUTPUT and then using another report procedure that would allow use of year and state as either page variables with the PAGE interval or by variables and the BYGROUP sheet interval.

 

 

sas_vegas
Calcite | Level 5

Thank you! I will try an an approach like that - do you know if there is a way to get the output to format in a manner similar to what is provided by the default surveyfreq procedure as below?

 

state_make_year.png

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 939 views
  • 0 likes
  • 2 in conversation