Hello expert,
Please, a method to avoid the warning
%let v=( &v1, &v2);
%macro chech;
proc sql;
select w1,w2 into:v1,v2
from toto;
insert into toto
values&v;
quit;
%mend;
%check;
We can't run this as is, it would definitely generate errors on our side since the macro variables aren't declared.
What errors/warning are you trying to suppress?
Copy the program and any warnings or errors from the log and paste into a code box opened by the {i} icon. The position of some characters of warnings or errors may be critical an pasting them into the forum without a code box removes the formatting.
When dealing with macros issues it also helps to use OPTIONS MPRINT.
WHICH WARNING?
Linemoon, you should be able by now to post a question in an answerable way. Postings like this are disappointing to us, it seems our tips fall on poor soil.
This is just overworking the problem from what I can see as:
data toto; set toto toto; run;
Is effectively what you are trying to do, dupicates toto rows. Your code will not work, the %let is outside the macro, and the select into is inside the macro. Anyways, don't do it like that, just do the above datastep.
@ll: Thank you
You can see the code and the log below :
SAS PGM :
data toto;
w1=1;
w2='TY';
run;
%let v=(&v1., "&v2.");
%macro prog;
proc sql;
select max(w1)+1,w2 into :v1,:v2
from toto;
insert into toto
values&v;
quit;
%mend;
%prog;
SAS LOG
%let v=(&v1., "&v2.");
WARNING: Apparent symbolic reference V1 not resolved.
WARNING: Apparent symbolic reference V2 not resolved.
%macro prog;
proc sql;
select max(w1)+1,w2 into :v1,:v2
from toto;
insert into toto
values&v;
quit;
%mend;
%prog;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: 1 row was inserted into WORK.TOTO.
You're creating v1 and v2 in a macro, so they are local to the macro. Use
%global v1 v2;
in the macro to put them into the global macro variable table.
And call the macro before using v1 and v2.
@ll: Thank you.
I know that. I do not need them to be "global"
For a global parameter , I need
%let v =(&v1,"&v2");
for avoid that's worning, I think about mask function
Do you want to assign the literal string '&v1' as part of the value of the macro variable V? If so the easiest way is to use a data step and call symputx() function.
data _null_;
call symputx('V','(&v1,"&v2")');
run;
@Tom : Thank you tom that's exact, there is "no warning " in the output.
But I need one line code and macro-variable indexed, f1, f2,...fn
%let f1=(&v1, "&v2");
%let fn=(&m1,&y2,"& h");
Then you need to create and populate &f1 to &fn as global variables inside your macro.
What are you expecting this line to do
values&v
You expect that to resolve to?
values (&v1, &v2)
If so, I don't think that logic is quite correct.
What is the larger problem that you are trying to solve? Perhaps there is an easy way that does not involve so many macro variables.
If the goal is to move data around then having the data in data sets is probably going to be much easier. It will also be more accurate since you can lose precision converting data into text to store in macro variables.
Why are you using macro variables?
Can't you just replace these two statements:
select max(w1)+1,w2 into :v1,:v2
from toto
;
insert into toto
values&v
;
with this one statement that does not need macro variables at all?
insert into toto
select max(w1)+1,w2
from toto
;
If SAS complains about reading and writing from the same table then introduce a temporary table.
create table temp as
select max(w1)+1 as w1,w2
from toto
;
insert into toto
select * from temp
;
@Tom :Thank you,
I prefere Fi=(&v1,"&v2.") and values&Fi.
because Fi can change
I can have
Fj=(&v1,"&v2",'test1',"&country",'',.);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.