Hi All
I have 10 data sets and it is save in my library as
dt_city_01; (data sets name)
dt_city_02;
dt_city_03; ............. so on to
dt_city_10.
I want to assign city into 1 macro variable and 01,02,03(so on to 10) into other macro variable.....
can any 1 help me out..
thanks in advance.
@vThanu wrote:
Hi All
I have 10 data sets and it is save in my library as
dt_city_01; (data sets name)
dt_city_02;
dt_city_03; ............. so on to
dt_city_10.
I want to assign city into 1 macro variable and 01,02,03(so on to 10) into other macro variable.....
Show us the results that you want. I'm afraid I don't find your explanation clear.
Also, where are these 10 data set names located? Are they in a text file, or an Excel file, or a SAS data set, or did you type them into your SAS program, or somewhere else?
SAS data sets (data set name itself saved as dt_city_01..... dt_city_10)....
This creates your dataset names:
%macro mymac(dspart=,number=);
%do i = 1 %to &number.;
%let dsnum=%sysfunc(putn(&i.,z2.));
%let dsname=dt_&dspart._&dsnum.;
%put dsname=&dsname.;
%end;
%mend;
%mymac(dspart=city,number=10)
Please find the attached document for your reference....
As per the attached document, I want to create Two macro variables - 1 for City and other for 01
Please post relevant information as text, many won't open office documents.
If you want to set a macro variable from the names of datasets, use a "select into" from dictionary.tables in proc sql.
I believe most people will understand what you have but it's a bit hard to understand what you want. What's normally really helpful is to get a desired result - like you giving us the name and content of the macro variables you're after in detail.
Below a code sample which hopefully will provide you the hints you need to make things working for you. Run the code and inspect the SAS log.
data work.dt_city_01 work.dt_city_02 work.dt_city_03;
set sashelp.class;
run;
proc sql noprint;
select
memname, memname
into :ds_name_mvar1-:ds_name_mvar99, :ds_name_list separated by ' '
from dictionary.tables
where libname='WORK' and memname like 'DT^_CITY^_%' escape '^'
;
quit;
%put &=sqlobs;
%put &=ds_name_list;
%macro PutCreatedMVars();
%put &=sqlobs;
%do i=1 %to &sqlobs;
%put ds_name_mvar&i: &&ds_name_mvar&i;
%end;
%mend;
%PutCreatedMVars()
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.
About cookies on this site
This site uses cookies and related technologies for site operation, analytics and third-party advertising purposes, as described in our SAS Privacy Statement. You may consent to our use of these technologies, reject non-essential technologies or further manage your preferences. To opt out of SAS making information relating to cookies and similar technologies available to third parties for advertising purposes, select "Required only." To exercise other rights you may have related to cookies, select "Manage cookies."