Hi,
i am having problems using mcros.Not getting the desired output
data cudata;
input ID Orderdate$ Model$12. Quantity ;
cards;
287 15OCT03 DeltaBreeze 15
287 15OCT03 SantaAna 15
274 16OCT03 JetStream 1
174 17OCT03 SantaAna 20
174 17OCT03 Noreaster 5
174 17OCT03 Scirocco 1
347 18OCT03 Mistral 1
287 21OCT03 DeltaBreeze 30
287 21OCT03 SantaAna 25
run;
%macro cus(dsn);
%if &sysday=Monday
%then %do;
proc print data=&dsn;
run;
%end;
%else %if &sysday=Thursday
%then %do;
proc tabulate data=&dsn;
class ID;
var Quantity ;
table ID,Quantity;
run;
%end;
%mend cus;
%cus(cudata);
log
The problem is most likely not with that code directly. If you run code which has an open quote, i.e. a quote mark with no closing mark, then SAS treates everything after that as being text. That is what the warning is telling you that it has read a certain amount of "text" and thinks you have unbalanced quote marks. Simplest solution, restart the SAS system to get a fresh session, and check any code you write to ensure all quoted strings is finished.
Also note, why bother with the whole macro thing? Just run a proc print an tabulate, takes a fraction of a second, then send out one or the other file.
This isnt a full solution for you.
But the macro part of your problem works fine.
That message is a warning that in future versions of SAS there will be a modification on how to use that style of code you tried for macros.
What version are you on? I'm on 9.4. so if you are on an earlier version that would explain things. and it hampers my ability to recreate the exact message.
I'd like to suggest a few things...
1. your data step isnt reading in your data correctly. Use: infile datalines truncover;
2. on things like the -tuesday- , -thursday-. Try with them in quotes.
3. the use of %macro cus(dsn); isnt bad - but might i suggest naming the macro variable? Its easier to read... Example: %macro cus(dsn=); then when you call it you can use: %cus(dsn=cudata); Its expecially helpful with a macro that has many variables.
hth
zeke torres
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.