How do I export .sas program to an excel tab?

Reply
Regular Learner
Posts: 1

How do I export .sas program to an excel tab?

Hi,

I'm trying to find a way to output the actual .sas program into an excel tab.  Is there a way to do this?

 

For example,

If my pretend.sas program consists of

 

Data one;

Set input_file;

Run;

 

Then I want to export this into excel as

 

Tab name: Pretend_sas

Starting in row A, Column 1 put

 

Data one;

Set input_file;

Run;

 

Thanks

Frequent Contributor
Posts: 108

Re: How do I export .sas program to an excel tab?

My First question would be why you need it as you wont be able to run it . I am not very sure if there is any way to do it . But you can try something like this make as variables and send the result to excel .
Grand Advisor
Posts: 17,396

Re: How do I export .sas program to an excel tab?

You'll need a saved version of the file to export. Then you could read it in as an infile and export to a tab in the sheet. 

Excel has cell limits for text that you might run into, so you also need to make sure it doesn't truncate your code.  

 

Maybe include a link to the saved program instead in a sheet?

 

I used to do this with my SQL queries for reproducibility but we also tracked projects by ID number.  There are other ways to ensure reproducibility than, ie Source Control and project tracking. All of them depend on user adherence.  

Grand Advisor
Posts: 9,584

Re: How do I export .sas program to an excel tab?

Yes. Transform your SAS program file into SAS Dataset ,and then export it as Excel.
CODE NOT TESTED:

data code;
infile 'c:\mycode.sas' length=len lrecl=800;
input code $varying800. len ;
run;

proc export data=code outfile='c:\myexcel.xls' dbms=excel replace;
 sheet='Pretend_sas';
run;

Ask a Question
Discussion stats
  • 3 replies
  • 331 views
  • 3 likes
  • 4 in conversation