Desktop productivity for business analysts and programmers

Export as a Step in project using code not wizard

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 83
Accepted Solution

Export as a Step in project using code not wizard

I want to write code similar to what the "export as a step in project" wizard does in Enterprise Guide.

I have the code to create the csv file with the delimiter ';'

proc export data=home.data

outfile='D:/testing/test.csv'

dmbs=csv replace;

delimiter=';' ;

run;

What I would like is to print the csv file within Enterprise Guide not just save it on the D:\ drive.  Similar to what the wizard does in "export as a step in project".  I would use the wizard, but I do not have the option to select a semi-colon.

Could I use proc import at this point?  Thanks for your help in advance.


Accepted Solutions
Solution
‎12-16-2014 11:35 AM
Trusted Advisor
Posts: 1,301

Re: Export as a Step in project using code not wizard

You can avoid creating the file and using PROC EXPORT by directing the delimited content to a temporary ODS file, which EG will then open to show you, sort of like the wizard does.  You are still writing the file, regardless of the method used.

options nodate nonumber pagesize=max;

ods _all_ close;

ods listing;

data _null_;

file print dsd dlm=';';

set sashelp.class;

put (_all_) (Smiley Happy;

run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,720

Re: Export as a Step in project using code not wizard

Hi,

I don't really use EG so can't comment on the "step" part.  I would say however that using a ";" delimiter means that the file is not a CSV (Comma Separated Variable file), so do try not to confuse the two.  You should not need dbms=csv:

proc export data=home.data outfile='D:/testing/test.dlm' replace;

     delimiter=';' ;

run;

So, not having access to the wizard, what do you mean print the file?  Do you mean actually output it to paper?

Frequent Contributor
Posts: 83

Re: Export as a Step in project using code not wizard

Hello

EG export wizard creates the text file and then places it on the process explorer so it is a physical file you can click and open. 
(I will remove the csv portion, thanks)

Solution
‎12-16-2014 11:35 AM
Trusted Advisor
Posts: 1,301

Re: Export as a Step in project using code not wizard

You can avoid creating the file and using PROC EXPORT by directing the delimited content to a temporary ODS file, which EG will then open to show you, sort of like the wizard does.  You are still writing the file, regardless of the method used.

options nodate nonumber pagesize=max;

ods _all_ close;

ods listing;

data _null_;

file print dsd dlm=';';

set sashelp.class;

put (_all_) (Smiley Happy;

run;

Frequent Contributor
Posts: 83

Re: Export as a Step in project using code not wizard

Can I print it to be a text file?  It is printing it as an ODS listing

Trusted Advisor
Posts: 1,301

Re: Export as a Step in project using code not wizard

ODS listing is, pretty much, a plain text file.  If you want it to be automatically displayed by EG, it is the only option I can think of.

Frequent Contributor
Posts: 83

Re: Export as a Step in project using code not wizard

I apologize, I figured how to then get the ods listing as a text file.

I do have one more question, the ods listing is putting a title before the data (ex: loaddata.sas).

loaddata.sas <---- title assigned I want removed

1;tere;kgm;1000 <---- start of data

Is there an option to write to remove this title?

Trusted Advisor
Posts: 1,301

Re: Export as a Step in project using code not wizard

An unfortunate side effect of this method (using the file statement with print destination) is that once a title is set, you are always going to start printing data on the second line of the text file, even when the title is null'd.

title 'loaddate.sas';

options nodate nonumber pagesize=max;

ods _all_ close;

filename x "D:/testing/test.csv" termstr=crlf;

ods listing file=x;

title; *null title;

data _null_;

file print dsd dlm=';';

set sashelp.class;

put (_all_) (Smiley Happy;

run;

Community Manager
Posts: 2,889

Re: Export as a Step in project using code not wizard

L,

You can use a combination of code and a download step to export the content to a location on the SAS server, and then transfer it to your local drive.  This technique requires the use of the Copy Files custom task.  See guidance in this blog post:

Export and download any file from SAS Enterprise Guide

Look at OPTIONS NODATE and NONUMBER and PAGESIZE=MAX to control some header/layout details.  See this topic for more information.

Chris

Frequent Contributor
Posts: 83

Re: Export as a Step in project using code not wizard

I added notitles to the file statement.

Thanks for your help everyone!

Trusted Advisor
Posts: 1,301

Re: Export as a Step in project using code not wizard

Adding notitles will work to suppress the title as well.  But, it still does not circumvent starting to print data on the second line of the text file.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 1737 views
  • 3 likes
  • 4 in conversation