Hi everyone,
I have an issue trying to combine a call symput with a superq.
Using a PROC SQL INTO I create a macro variable cc which is something like
'1','5','13'
I want this macrovariable to be global and do this:
data _null_; call symput(cci,%superq(cc)); run;
But then I get this issue:
MPRINT(EXT): data _null_; MPRINT(EXT): call symput(cci,'1','5','13'); MPRINT(EXT): run; NOTE: The SAS System stopped processing this step because of errors. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds NOTE: Line generated by the macro function "SUPERQ". 163 '1','5','13' _ 386 76 ERROR 386-185: Expecting an arithmetic expression.
ERROR 76-322: Syntax error, statement will be ignored.
Do you know what's wrong here?
Thanks for reply.
Why don't you do a simple
%global cc;
before you create cc in the SQL step?
Why don't you do a simple
%global cc;
before you create cc in the SQL step?
Thanks to all for replies.
The easiest, the best.
I didn't thik about this 😞
You can make it global by just using "%global your_macro_variable;," but this assumes it isn't global already. Are you creating it inside a macro and that is making it local?
Well, you could do it:
data _null_; call symput('cci',"'1','5','13'"); run; %put &cci.;
The real question is why. It is never a good idea to put quotes into a macro variable. Second, it is rarely a good idea to put lists into a macro variable. There are far better, simpler methods of working with data if you use Base SAS which is the programming language, rather than Macro which is a text generator.
What is the actual question here?
If you want to make a macro variable named CCI that has the quoted value of the macro varaible CC then you could just write.
%global cci;
%let cci=%superq(cc);
If you want to create CC as global and populate its value using SQL INTO clause then just define it as global before writing to it.
proc sql noprint;
%global cc ;
select x into :cc separated by ',' ....
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.
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.