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;

 


 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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