BookmarkSubscribeRSS Feed
radha009
Quartz | Level 8

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;

 

2 REPLIES 2
Reeza
Super User

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;

 


 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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