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

they dont have sas access at work so i have to convert the file to csv before  export it but i get errors

this is the code  i am writing:

proc export data=mylib.susp_reasons_previous outfile'C:\Users\tiliev\Desktop\report.csv' replace;     

sheet='susp_reasons_previous';run;

and this is the error  i am  getting:

1259  proc export data=mylib.susp_reasons_previous outfile=  'C:\Users\tiliev\Desktop\report.csv'

1259!  replace;

NOTE: The previous statement has been deleted.

1260  sheet='susp_reasons_previous';

      -----

      180

ERROR 180-322: Statement is not valid or it is used out of proper order.

Does anyone see what i am  doing wrong here,pleasE?

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

I believe the sheet statement is only used with excel exports, not csv's.

View solution in original post

12 REPLIES 12
DBailey
Lapis Lazuli | Level 10

I believe the sheet statement is only used with excel exports, not csv's.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

hmm,

so any idea how to export csv  files except through  the wizard?

Jagadishkatam
Amethyst | Level 16

Hi,

Please try this

proc export data=mylib.susp_reasons_previous outfile'C:\Users\tiliev\Desktop\report.csv' dbms=csv replace;     

sheet='susp_reasons_previous$';

run;


Thanks,

Jagadish

Thanks,
Jag
Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

yea  i did,still the same error.Probably "sheet" cant be used with csv as DBailey said

AncaTilea
Pyrite | Level 9

I agree, there is no way to name your sheetname when using CSV.

One work around it would be to name the file you are creating as the sheet-name.

For exmaple:

proc export data=mylib.susp_reasons_previous outfile'C:\Users\tiliev\Desktop\susp_reasons_previous.csv' replace;     

sheet='susp_reasons_previous';run;


Good luck!


Anca.

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thank  you guys,

i do need all the query outputs to be on different worksheets of one excel file so i can have my  table populated easily but i guess ODS
TAGSETS.EXCELXP
would be the only way to do so?

AncaTilea
Pyrite | Level 9

So, then why don't your create an EXCEL file, instead of CSV?

Something like this:

%macro to_export(var = );

    proc export data = sashelp.class (where=(sex="&var."))

       outfile='file_path\Master_file.xls'

       dbms=excel;

       sheet="&var";

    quit;

%mend to_export;

%to_export(var = F);

%to_export(var = M);

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

but i cant export an excel file.I tried it before.We dont have sas access here

AncaTilea
Pyrite | Level 9

I see.

then ODS TAGSETS.EXCELXP is what you need.

See here more helpful info:

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

yeaa  but that works too Smiley Happy

Thanks  for all your  help Anca and team,

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

we dont have sas access to pc files  but we have to ole db.Is there a way i can import/export excel files through it?

DBailey
Lapis Lazuli | Level 10

try this:

proc export data=mylib.susp_reasons_previous outfile'C:\Users\tiliev\Desktop\report.xls' dbms=csv replace;     

run;



When you try to open the file with excel, you might get an error message that says the file is in a different format than the file extension, but if you click OK, excel should open the 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!

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.

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