Help using Base SAS procedures

Export to Excel -- dynamic file name

Reply
N/A
Posts: 0

Export to Excel -- dynamic file name

Hi -- has anyone exported to Excel using a dynamic, variable filename? I have a global variable with value assigned by a "%let" statement that I want to set to the Excel file name that I'm exporting to. I've seen DDE documentation and a macro called %exporttoXL, but I'm not sure that extent is needed or whether either approach will suit my simple need here. THanks for any tips!
Super Contributor
Super Contributor
Posts: 3,174

Re: Export to Excel -- dynamic file name

Posted in reply to deleted_user
Please explain more about what determines the "dynamic, variable filename"? Also, have you considered PROC EXPORT and using the macro variable approach to resolve the PC file name in a prior DATA step or PROC SQL (again, your advance SAS processing component has not been stated/identified at this point).

Scott Barry
SBBWorks, Inc.

PROC EXPORT Statement
http://support.sas.com/documentation/cdl/en/acpcref/61891/HTML/default/a003102702.htm
N/A
Posts: 0

Re: Export to Excel -- dynamic file name

Hi -- I'm on v 9. Your suggestion about using a macro is something I had tried, except I was using a constant string value concatenated with a macro variable for the file name. Instead, I will try putting everything including the constant string in the macro variable rather than trying to do the concatenation. Thanks
SAS Super FREQ
Posts: 8,868

Re: Export to Excel -- dynamic file name

Posted in reply to deleted_user
Hi:
You can concatenate a constant string with macro variables. Consider the LOG view of some %LET statements and the resulting %PUT output. You just have to remember the rules of how to concatenate and reference macro variables.

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001071889.htm
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a001071915.htm
http://www.nesug.org/proceedings/nesug03/bt/bt009.pdf
http://www2.sas.com/proceedings/sugi28/056-28.pdf


cynthia
[pre]
SAS LOG:
453 %let path= c:\temp;
454 %let name= fred;
455 %let ext = xls;
456
457 %let pathfile=&path\&name;
458 %let pne = &path\&name..&ext;
459 %let othr = &path\fixed\part\&name..&ext;
460
461 %put path is: &path;
path is: c:\temp
462
463 %put name is: &name;
name is: fred
464
465 %put ext is: &ext;
ext is: xls
466
467 %put pathfile is: &pathfile;
pathfile is: c:\temp\fred
468
469 %put pne is: &pne;
pne is: c:\temp\fred.xls
470
471 %put othr is: &othr;
othr is: c:\temp\fixed\part\fred.xls

[/pre]
Ask a Question
Discussion stats
  • 3 replies
  • 1907 views
  • 0 likes
  • 3 in conversation