BookmarkSubscribeRSS Feed
vomer
Obsidian | Level 7

Hi Guys,

I am wondering if this is possible?

Basically if I have 2 excel files : File1.xls and File2.xls

Can I use SAS to say: Take all rows/columns from file1.xls and put them (starting at a specific cell) in File2.xls?

The next part of my question is...can I do the same for specific cell ranges? So Cells A1:A10 from File1.xls to Cells N1:N10 in File2.xls

Please provide sample codes if possible Smiley Happy

Thanks!

3 REPLIES 3
art297
Opal | Level 21

Does your site have SAS Access/PC files?

vomer
Obsidian | Level 7

Yes they do.

art297
Opal | Level 21

Not sure why I asked about SAS Access, as the export procedure doesn't allow one to use a range statement.

Thus, I used DDE to export the file.  If you're not familiar with DDE, you can find numerous examples on the web.

I took a shortcut and simply opened the desired output file manually.  You would probably want to do all of that programmatically .. which is definitely possible.

Below, I use proc import to import the desired range, then output it to a different range on another spreadsheet:

PROC IMPORT OUT= WORK.have;

DATAFILE= "C:\art\abc.xls"

DBMS=excel REPLACE;

range='feb2012$A1:A27'n;

GETNAMES=no;

Run;

filename dataout dde "excel|[cba.xls]Sheet1!r1c14:r27c14" notab;

data _null_;

set have;

file dataout;

put f1 $20.;

run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 887 views
  • 0 likes
  • 2 in conversation