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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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