BookmarkSubscribeRSS Feed
Daily1
Quartz | Level 8
proc export
data=sashelp.class 
outfile="TEST1"
dbms = xlsx replace;
run;

proc export data=sashelp.class
  outfile="TEST1"
  dbms=xlsx
  replace;
run;

I'm trying to append an existing file using Proc export, but it didn't work.

i want this ouput

Daily1_0-1715855445572.png

 

2 REPLIES 2
LinusH
Tourmaline | Level 20

I haven't seen a way of controlling this from within PROC EXPORT.

What you can do though is to take the generated data step code generated by PROC EXPORT, and add the MOD option to the FILE statement option:

 /**********************************************************************
  *   PRODUCT:   SAS
  *   VERSION:   9.4
  *   CREATOR:   External File Interface
  *   DATE:      16MAY24
  *   DESC:      Generated SAS Datastep Code
  *   TEMPLATE SOURCE:  (None Specified.)
  ***********************************************************************/
     data _null_;
     %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
     %let _EFIREC_ = 0;     /* clear export record count macro variable */
     file 'c:\Temp\sashelp_class.csv' delimiter=',' DSD DROPOVER lrecl=32767 mod;
     if _n_ = 1 then        /* write column names or labels */
      do;
        put
           "Name"
        ','
           "Sex"
        ','
           "Age"
        ','
           "Height"
        ','
           "Weight"
        ;
      end;
    set  SASHELP.CLASS   end=EFIEOD;
        format Name $8. ;
        format Sex $1. ;
        format Age best12. ;
        format Height best12. ;
        format Weight best12. ;
      do;
        EFIOUT + 1;
        put Name $ @;
        put Sex $ @;
        put Age @;
        put Height @;
        put Weight ;
;
      end;
     if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
     if EFIEOD then call symputx('_EFIREC_',EFIOUT);
run;
Data never sleeps
Ksharp
Super User

It is impossible for PROC EXPORT to append the data into existed XLSX file.

But you could try LIBNAME + PROC SQL or PROC APPEND to workaround it.

 

proc export
data=sashelp.class 
outfile="c:\temp\temp.xlsx"
dbms = xlsx replace;
sheet='xxxx';
run;

libname x excel "c:\temp\temp.xlsx"  SCAN_TEXT=NO;
proc append base=x.xxxx data=sashelp.class force;run;
libname x clear;

Ksharp_0-1715910240636.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 320 views
  • 1 like
  • 3 in conversation