BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5
%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
Calcite | Level 5
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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 5 replies
  • 766 views
  • 0 likes
  • 4 in conversation