BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LAtwood
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

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_) (:);

run;

View solution in original post

10 REPLIES 10
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

LAtwood
Calcite | Level 5

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)

FriedEgg
SAS Employee

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_) (:);

run;

LAtwood
Calcite | Level 5

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

FriedEgg
SAS Employee

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.

LAtwood
Calcite | Level 5

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?

FriedEgg
SAS Employee

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_) (:);

run;

ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
LAtwood
Calcite | Level 5

I added notitles to the file statement.

Thanks for your help everyone!

FriedEgg
SAS Employee

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 10 replies
  • 5841 views
  • 3 likes
  • 4 in conversation