syntaxsasexportspss

SAS no longer automatically converts user-defined formats to SPSS value labels


I work in SAS 9.4 and my team works in SPSS 27. It used to be the case that when I exported a SAS dataset to SPSS, it would automatically transform the SAS user-defined formats into SPSS value labels. This no longer is happening. It's been awhile since I've needed to do this and we've probably been made to update SPSS since then but I can't recall. Does anyone know how to fix this? Here is my syntax:

proc export data=pids_insurance6
outfile='C:\Users\Dropbox\EHE\Data_Meeting_4.25.23\Insurance_Dataset_merged_Rx_pt_key.SAV'
replace
dbms=spss;
run;

I have also tried this:

proc export data=pids_insurance6
outfile='C:\Users\Dropbox\EHE\Data_Meeting_4.25.23\Insurance_Dataset_merged_Rx_pt_key.SAV'
replace
dbms=sav;
run;

Thank you


Solution

  • Make sure that the formats can be found in one of the format catalogs listed in the FMTSEARCH system option setting.

    Make sure the format names are short (7 or 8 characters max).

    Make sure that the formats are simple one to one mappings.

    Here is an example program to make a dataset that is using three simple formats and one complex one.

    proc format lib=work.formats;
      value gender 0='0=Male' 1='1=Female' ;
      value $sex 'M'='M=MALE' 'F'='F=FEMALE';
      value agesimp 11='11-13=Young' 12='11-13=Young' 13='11-13=Young'
                    14='14-16=Old' 15='14-16=Old' 16='14-16=Old'
      ;
      VALUE AGECOMP 11-13='11-13=YOUNG' 14-16='14-16=OLD';
    run;
    
    data class;
      set sashelp.class(obs=3);
      gender=(sex='F');
      age2=age;
      format gender gender. sex $sex. age agesimp. age2 agecomp.;
    run;
    
    filename sav temp;
    proc export dbms=sav data=class file=sav;
    run;
    

    If you just look at the SAV file

    data _null_;
      infile sav lrecl=100 recfm=f ;
      input;
      list;
    run;
    

    you can see that the simple format information, "data values", got loaded but the complex one with uppercase YOUNG and OLD did not.

    enter image description here