Tuesday, March 31, 2015

Saving SAS data sets from SAS 9.4 to earlier versions (SAS 9.3, SAS 9.2)

Now that I have a chance to use SAS 9.4, the first issue is the compatibility issue for the data sets created from SAS 9.4.

There is no difference in SAS data sets between SAS 9.4 and its earlier versions (SAS 9.3 and SAS 9.2). however, the default for  EXTEND OBS COUNTER is different.

In order for data sets created under SAS 9.4 to be read in earlier SAS versions, an option of  EXTENDOBSCOUNTER=NO must be used.

See SAS communication "Extending the Observation Count for a 32-Bit SAS Data File" for details.

libname myfiles 'C:\MyFiles';

data myfiles.bigfile (extendobscounter=no);
   .
   .
   .
run;




libname new 'C:\NewFiles' extendobscounter=no;
libname old 'C:\OldFiles';

proc copy in=old out=new;
run;




libname old "c:\xyz";
options extendobscounter=no;
libname new "c:\abc";

data new;
  set old;
run;




Sunday, December 15, 2013

Using proc cimport and proc cport

Warning: don't use Proc Cport to generate SAS transport file for submitting the data to FDA. See my article "Submit the Clinical Trial Datasets to FDA: Using the right .xpt file format"

Proc CPORT to creat SAS transport file

***This program will transfer all SAS data sets under c:\sourcedata directory 
***to a single .xpt file called test.xtp;

filename xptfile "c:\temp\test.xpt";
libname source "c:\sourcedata\";

***For converting a data set;
proc cport library=source file=xptfile memtype=data;
run;

***For converting a format catalog;
proc cport library=source file=xptfile memtype=catalog;
run;


Proc CIMPORT to extract SAS transport file


/*********************************************************************
/*  This program is used for extract the data from SAS transport file
/*  generated by using PROC CPORT
/*********************************************************************;

FILENAME xpt 'transport_file_name.xpt'; 
libname dest 'destination_directory_name'; 

PROC CIMPORT INFILE= xpt  LIBRARY=Dest; 
RUN;