Desktop productivity for business analysts and programmers

Global statement not supported in proc sql

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Global statement not supported in proc sql


Hi,

I am trying to use macro to do a one year forward performance track for the origination period 201202 - 201207. So if the origination month is 201202, i will track the month from 201202 to 201301 to see how origination performs. After I run the code, there is warning ' This SAS global statement is not support in proc sql' which causes my proc sql not working properly.

%macro monthly (first,last);

%do mon=&first &to &last;

%let monthend=%eval(&mon+99);

proc sql;

create table test&mon as

select*

from aaa_&mon as a left join master_file

on num=num;

where &mon<=YEAR_MONTH<=&monthend;

quit;

%end;

%mend monthly;

%monthly(201202,201207);

Have any idea what causes the warning?

Thanks in advance!

Frank


Accepted Solutions
Solution
‎11-21-2013 09:29 PM
Trusted Advisor
Posts: 1,137

Re: Global statement not supported in proc sql

I believe the %do block is not correct, you have used &to instead of %to. Please check and change it to %to.

also remove the semicolon after num=num; i.e., before the where clause.

Please check the updated code below

%macro monthly (first,last);

%do mon=&first %to &last;

%let monthend=%eval(&mon+99);

proc sql;

create table test&mon as

select*

from aaa_&mon as a left join master_file as b

on a.num=b.num

where &mon<=YEAR_MONTH<=&monthend;

quit;

%end;

%mend monthly;

%monthly(201202,201207);

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎11-21-2013 09:29 PM
Trusted Advisor
Posts: 1,137

Re: Global statement not supported in proc sql

I believe the %do block is not correct, you have used &to instead of %to. Please check and change it to %to.

also remove the semicolon after num=num; i.e., before the where clause.

Please check the updated code below

%macro monthly (first,last);

%do mon=&first %to &last;

%let monthend=%eval(&mon+99);

proc sql;

create table test&mon as

select*

from aaa_&mon as a left join master_file as b

on a.num=b.num

where &mon<=YEAR_MONTH<=&monthend;

quit;

%end;

%mend monthly;

%monthly(201202,201207);

Thanks,

Jagadish

Thanks,
Jag
Occasional Contributor
Posts: 12

Re: Global statement not supported in proc sql

Thanks so much. It works now!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 2334 views
  • 0 likes
  • 2 in conversation