i have a spreadsheet with unknown tab names and count with ticket number. i varlist all the tab names. Now using varlist tab names from I want to import data and create for each a table. Please help me
proc sql noprint;
select memname into :varlist1 separated by ' '
from sashelp.vtable
where
libname="XLS"
and memname like '%TKT%';
quit;
from the above all tabs containing tkt are in varlist1. Now i want to loop number of tabs and import data into different tables. ex: i have 3 tab names in varlist1 ( TKT _ SSH, TKT_Weblogic , TKT_PATCH). Please let me know how can i create multiple tables
PROC IMPORT OUT = work.file
DATAFILE="&filepath"
DBMS=XLSX;
Sheet=&varList1.;
getnames = yes;
RUN;
If you already have a libname set up why not use PROC COPY instead. It will copy all worksheets into SAS at once.
You may be able to use the wildcard approach there, not sure if the SELECT statement wildcard will work as shown but it's easy enough to remove.
libname myfiles xlsx 'path tomy excel file';
proc copy in=myfiles out=work;
select TCK_:;
run;
@radha009 wrote:
i have a spreadsheet with unknown tab names and count with ticket number. i varlist all the tab names. Now using varlist tab names from I want to import data and create for each a table. Please help me
proc sql noprint;
select memname into :varlist1 separated by ' '
from sashelp.vtable
where
libname="XLS"
and memname like '%TKT%';
quit;
from the above all tabs containing tkt are in varlist1. Now i want to loop number of tabs and import data into different tables. ex: i have 3 tab names in varlist1 ( TKT _ SSH, TKT_Weblogic , TKT_PATCH). Please let me know how can i create multiple tables
PROC IMPORT OUT = work.file
DATAFILE="&filepath"
DBMS=XLSX;
Sheet=&varList1.;
getnames = yes;
RUN;
Thanks it works
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.