Help using Base SAS procedures

proc export

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 444
Accepted Solution

proc export

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?


Accepted Solutions
Solution
‎01-29-2013 09:56 AM
Super Contributor
Posts: 578

Re: proc export

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

View solution in original post


All Replies
Solution
‎01-29-2013 09:56 AM
Super Contributor
Posts: 578

Re: proc export

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

Super Contributor
Super Contributor
Posts: 444

Re: proc export

hmm,

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

Trusted Advisor
Posts: 1,137

Re: proc export

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
Super Contributor
Super Contributor
Posts: 444

Re: proc export

Posted in reply to Jagadishkatam

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

Super Contributor
Posts: 543

Re: proc export

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.

Super Contributor
Super Contributor
Posts: 444

Re: proc export

Posted in reply to AncaTilea

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?

Super Contributor
Posts: 543

Re: proc export

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);

Super Contributor
Super Contributor
Posts: 444

Re: proc export

Posted in reply to AncaTilea

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

Super Contributor
Posts: 543

Re: proc export

I see.

then ODS TAGSETS.EXCELXP is what you need.

See here more helpful info:

Super Contributor
Super Contributor
Posts: 444

Re: proc export

Posted in reply to AncaTilea

yeaa  but that works too Smiley Happy

Thanks  for all your  help Anca and team,

Super Contributor
Super Contributor
Posts: 444

Re: proc export

Posted in reply to AncaTilea

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?

Super Contributor
Posts: 578

Re: proc export

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.


🔒 This topic is solved and locked.

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

Discussion stats
  • 12 replies
  • 608 views
  • 3 likes
  • 4 in conversation