DATA Step, Macro, Functions and more

Email Macro

Reply
Occasional Contributor
Posts: 16

Email Macro

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;

Super User
Super User
Posts: 7,407

Re: Email Macro

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.

PROC Star
Posts: 1,233

Re: Email Macro

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.

Ask a Question
Discussion stats
  • 2 replies
  • 206 views
  • 7 likes
  • 3 in conversation