☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-09-2023 04:53 PM
(6212 views)
I am trying to use proc sql select into to create some macro variables as follows.
%macro sql(var);
proc sql noprint;
select A into: &var. separated by ' ' from in_ds;
quit;
%mend;
%sql(B);
%sql(C);
......
Seems it is not working, tried "&var.", didn't work either. Just wonder how to fix this, thanks.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Unless you use a %GLOBAL statement your macro variables will only be defined within your macro and not available outside of it. Try this:
%macro sql(var);
%global &var.;
proc sql noprint;
select A into: &var. separated by ' ' from in_ds;
quit;
%mend;
%sql(B);
%sql(C);
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Unless you use a %GLOBAL statement your macro variables will only be defined within your macro and not available outside of it. Try this:
%macro sql(var);
%global &var.;
proc sql noprint;
select A into: &var. separated by ' ' from in_ds;
quit;
%mend;
%sql(B);
%sql(C);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
it works, thanks a lot!