BookmarkSubscribeRSS Feed
ettinenivarma
Fluorite | Level 6

In aetox varaible i had distinct values as mild,moderate and death

 

proc sql ;
select distinct(AETOXGRC) into :var1-:var9999
from ae;
quit;

%put &var1-&var9999;

 

when i call we get " WARNING: Apparent symbolic reference VAR9999 not resolved." need to supress this warning is there any option in sas ,why &var9999 because when there update to varaible this consider with out changing
code

6 REPLIES 6
Astounding
PROC Star

You're getting the message when fewer than 9999 macro variables were needed to hold the result.  Worth a try:

 

%put &var1-&&var&sqlobs;

 

Update:  While I verified that this code works, your intent may be different.  It is conceivable that you are looking to write out the value of all macro variables created here.  (We really didn't discuss the intent of your program, only how to eliminate a warning.)  If that's the case, this is simple but prints extra information:

 

%put _user_;

 

For a cleaner version, you would need to add this code.  Assuming you are working within a macro definition so that %DO is permissible:

 

%do i = 1 %to &sqlobs;

   %put var&i = &&var&i;

%end;

ettinenivarma
Fluorite | Level 6

 

This works:-


proc sql ;
select distinct(AETOXGRC) into :var1-:var9999
from ae;
quit;

%let varcount = &Sqlobs;

%put &&var&varcount;
%macro putit;
%do i=1 %to &sqlobs;
%put var&i = &&var&i;
%end;
%mend putit;
%putit

 

Thanks for your time,The challenge will come when we call seperate (&var1,&var2...) macro varaible  for other calculation again we need to check data , i will try standize this as well... thanks alot

Kurt_Bremser
Super User

There will only be macrovars created for the distinct values. If you only have 3 distinct values in the dataset (as indicated), only three macro vars will be there after the step.

 

ettinenivarma
Fluorite | Level 6

@Kurt_Bremser@Yes ur correct, but when I call macro I need to suppress warning.

ballardw
Super User

@ettinenivarma wrote:

@Kurt_Bremser@yes ur correct, but when I call macro I need to suppress warning.


Then do not reference a variable you that you do not know exists.

When you run:

proc sql ;
select distinct(AETOXGRC) into :var1-:var9999
from ae;
quit;

an automatic macro variable SQLOBS is assigned to the number of output observations in Proc SQL (or macro vars in this case).

So capture that for reuse (as the sqlobs will reset for every Proc SQL call)

%let varcount = &Sqlobs;

 

And instead of &var9999 use &&var&varcount;

 

 

ettinenivarma
Fluorite | Level 6

Thanks for response , when we use &&var&varcount; we get  Severe that is last value but in dataset we have 3 unique macrovaribles all these three need to store in your macro varaible.

 

I am trying create a macro varaible which should contain all unique values  , For example if in var1- mild var2-moderate v3-severe but i want to use :var9999 because when there is update to my data i should not change my macro varaible to var4 etc....

 

Thanks for your help

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 987 views
  • 3 likes
  • 4 in conversation