BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
FediSimi_333
Fluorite | Level 6
Can someone help me?  I can't see my error 😞
 
&column_name. and &product. are already defined as list of name separated by *
 
%macro Esegui;
%do i = 1 %to  &n_column_sales.;
%let Variabile = %SCAN(&column_name.,&i.,'*');
%do j= 1 %to 2
%let product_ =  %SCAN(&product.,&j.,'*'); 
 
proc sql; 
create table lib.&variabile. as
select 
count(column) as quanti
,   CG 
,   &variabile.
from tab
where product= "&product_."
group by 2,3
;quit;
     %end;
    %end;
    %mend;  
%Esegui;
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Well, you didn't post anything to show what the error might be.  So here are a couple of guesses.

 

There's a missing semicolon to end this statement:  %do j= 1 %to 2

 

The delimiter for the %scan function is likely incorrect.  Macro language does not need quotes to show what is text and what is a significant name.  Instead, macro language uses & to show what is a significant name.  So '*' as a delimiter means to use asterisks and single quotes as possible delimiters.  It gets you the right answer as along as your values do not contain any single quotes.  (Of course if your values do include single quotes, those might generate other problems.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

When you have a macro and are trying to debug it, turn on the macro debugging options by running this command

 

options mprint;

 

and then run the macro, and show us the entire log for this macro (or the log down to this particular error).

 

 

--
Paige Miller
FediSimi_333
Fluorite | Level 6

Many thanks for your suggestions!

Astounding
PROC Star

Well, you didn't post anything to show what the error might be.  So here are a couple of guesses.

 

There's a missing semicolon to end this statement:  %do j= 1 %to 2

 

The delimiter for the %scan function is likely incorrect.  Macro language does not need quotes to show what is text and what is a significant name.  Instead, macro language uses & to show what is a significant name.  So '*' as a delimiter means to use asterisks and single quotes as possible delimiters.  It gets you the right answer as along as your values do not contain any single quotes.  (Of course if your values do include single quotes, those might generate other problems.

FediSimi_333
Fluorite | Level 6
that semicolon was driving me cr4sy! Many thanks!! 😁

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 589 views
  • 2 likes
  • 3 in conversation