BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
Hi

i have a Excel in this i have 24 sheets sheet1 to sheet24 all this sheets have same variables how can i import all the sheets at once.
2 REPLIES 2
Peter_C
Rhodochrosite | Level 12
use sas libname engine for excel, like[pre] libname ex 'your.work.book.xls' ;[/pre]Unfortunately, to copy all sheets into the work library:[pre] proc copy in= ex out= work ;
run ; [/pre]didn't work for me. Not even with [pre]option validvarname= ANY ;[/pre]However, this copies sheet1[pre]data s1; set ex."sheet1$"n ; run;[/pre]So, you could use a macro loop, or more simple CALL EXECUTE(), like[pre] data _null_ ;
do ns= 1 to 24 /*yoursheet count*/ ;
ds = 'S' !! put( ns, 2.-L );
sh = 'sheet' !! put( ns, 2.-L );
call execute( 'data ' !! ds ) ;
call execute( '; set ex."' !! trim(sh)!! '$"n ; run; ' ) ;
end;
run;[/pre]...... it works for me.
Then you can work with the 24 data sets in the work library named S1 to S24.

good luck

PeterC
Andre
Obsidian | Level 7
a little addon is neccessary in case your nine first sheet names are
written as sheet01-sheet09 in place of sheet1-sheet-9 sheet10-sheet24

Change this line in forwarded code
sh = 'sheet' !! put( ns, z2.-L );

Andre

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 642 views
  • 0 likes
  • 3 in conversation