Help using Base SAS procedures

export an empty dataset to excel

Reply
Contributor
Posts: 51

export an empty dataset to excel

Hello, All

I have an empty dataset:

data test;

length var1 8 var2 $ 8 var3 8;

label var1='label for variable 1'

      var2='label for variable 2'

      var3='label for variable 1'

      ;

stop;

run;

Now I want to export this empty dataset to excel, using the label as the first row in excel:

proc export data=test

                   outfile='c:\temp\test.xlsx'

                  label

                 dbms=excel replace;

run;

However I got following error message:

ERROR: Error attempting to CREATE a DBMS table. ERROR: Execute: Field 'label for variable 1'

already exists in table 'TEST'..

I actually found this post ;  but it does not seem to work for exporting an empty dataset.

Is there a way to make such export possible? Thanks.

Super User
Posts: 11,336

Re: export an empty dataset to excel

Depending on your needs, exporting as a CSV seems to work. File will need a CSV instead of XLSX extension but can still open in Excel then save as if needed.

Ask a Question
Discussion stats
  • 1 reply
  • 680 views
  • 0 likes
  • 2 in conversation