BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6
%let count=6;
Proc SQL Noprint;
Select distinct (age) into:A1-:A%left(&count) from sashelp.class;
Quit;
%put &A1 &&A&count;
How to see the value is assigned or not in last macro variable
&A1--------- it is showing some value
&&A&count------it is not
5 REPLIES 5
Kurt_Bremser
Super User

It IS showing, see this log of your code:

24         %let count=6;
25         Proc SQL Noprint;
26         Select distinct (age) into:A1-:A%left(&count) from sashelp.class;
27         Quit;
NOTE: PROZEDUR SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

28         %put &A1 &&A&count;
11 16
thanikondharish
Fluorite | Level 6
Sorry previous something happened
ballardw
Super User

@thanikondharish wrote:
Sorry previous something happened

Then show the entire log of what happens when you run your code.

I believe that we have asked for your do provide LOG results in the past. Again,

Tom
Super User Tom
Super User

The INTO clause only creates the macro variables that it needs.  So if the query result had less than 6 observations then less than 6 macro variables will be written.

 

Tom
Super User Tom
Super User

Why are you setting COUNT before you run the query?  Why do you have the %LEFT() call?  Does you value of COUNT have leading spaces? Why did you put leading spaces into the macro variable COUNT?  Also why are you only calling %LEFT() in one of the two places you use count?

 

SAS can count for you. No need to count in advance or set an upper limit on the number of macro variables to create.

 

proc sql noprint;
  select distinct (age) into :A1- from sashelp.class;
%let count=&sqlobs;
quit;
%put &=count &A1 &&A&count;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1381 views
  • 0 likes
  • 4 in conversation