DATA Step, Macro, Functions and more

symput with superq

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

symput with superq

[ Edited ]

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.


Accepted Solutions
Solution
‎07-18-2017 10:26 AM
Super User
Posts: 6,951

Re: symput with superq

Why don't you do a simple

%global cc;

before you create cc in the SQL step?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎07-18-2017 10:26 AM
Super User
Posts: 6,951

Re: symput with superq

Why don't you do a simple

%global cc;

before you create cc in the SQL step?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 23

Re: symput with superq

Thanks to all for replies.

The easiest, the best. 

I didn't thik about this :-(

PROC Star
Posts: 288

Re: symput with superq

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?

Super User
Super User
Posts: 7,411

Re: symput with superq

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.

Super User
Super User
Posts: 6,502

Re: symput with superq

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 ',' ....
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 169 views
  • 2 likes
  • 5 in conversation