BookmarkSubscribeRSS Feed
thomask23
Fluorite | Level 6

I am new to SAS.  I have started a macro that creates a file each time a Rectype has an outlier identified in the control chart.  I would like to create a new file each RecType has a outlier identifed in the shewhart statement for the most recent month.  I have tried adding the variable(&RecType) in the ODS File statement, however I have had no luck.  Any suggestions?


ODS PDF FILE="C:\Desktop\OUTLIERS2.pdf" &RecType;  STYLE=OCEAN;
%Let Heading=RecType

proc shewhart data=work.OUTLIERS2; xchart _SUBX_* MONYEAR /sigmas=2; run;
RUN;
ODS PDF CLOSE;
ods listing;

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Not sure what you are trying to do, is this all your code?  Does the rectype come from the output of the shewhart procedure or is it something you put in by hand.  The definition of the macro variable needs to appear before the actual use.  So you could do:

%let rectype=recordtype;

%let headin=This is a &rectype. heading;

You have other errors there though.  For instance you have a semicolon after your &recType macro reference which means the style is invalid.  Macro variables are delimited by a dot, e.g. &RecType. style=ocean.

As for the line:

ODS PDF FILE="C:\Desktop\OUTLIERS2.pdf" &RecType;  STYLE=OCEAN;

What is RecType to be as there is no option on an ods line (except select/exclude)?

Perhaps provide a clear example with test data of what you have and what you want.

Quentin
Super User

Hi,

If you really are new to SAS, be careful with how soon you start writing macros.  The (main) purpose of the macro language is to generate SAS code.  Usually it makes sense to spend time writing (and debugging) your own SAS code until you are comfortable with that, before adding in the complexity of automated code generation.  There is plenty you can do with SAS without worrying about macros.  Even non-macro ways to do code generation.

That said, if you are sure you want to dive in to macros, sometimes a way to start is to write your SAS code first and get it working, and then convert it into a macro.

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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
  • 2 replies
  • 853 views
  • 7 likes
  • 3 in conversation