Stata 11 help for fdause

help fdasave, help fdause, dialogs: fdasave fdause help fdadescribe -------------------------------------------------------------------------------

Title

[D] fdasave -- Save and use datasets in FDA (SAS XPORT) format

Syntax

Save data in memory in FDA format

fdasave filename [if] [in] [, fdasave_options]

fdasave varlist using filename [if] [in] [, fdasave_options]

Read SAS XPORT file into Stata

fdause filename [, fdause_options]

Describe contents of SAS XPORT Transport file

fdadescribe filename [, member(mbrname)]

fdasave_options description ------------------------------------------------------------------------- Main rename rename variables and value labels to meet SAS XPORT restrictions replace overwrite files if they already exist vallabfile(xpf) save value labels in formats.xpf vallabfile(sascode) save value labels in SAS command file vallabfile(both) save value labels in formats.xpf and in a SAS command file vallabfile(none) do not save value labels -------------------------------------------------------------------------

fdause_options description ------------------------------------------------------------------------- clear replace data in memory novallabels ignore accompanying formats.xpf file if it exists member(mbrname) member to use; seldom used -------------------------------------------------------------------------

Menu

fdasave

File > Export > FDA data (SAS XPORT)

fdause

File > Import > FDA data (SAS XPORT)

Description

fdasave, fdause, and fdadescribe convert datasets to and from the U.S. Food & Drug Administration (FDA) format for new drug and new device applications (NDAs) -- SAS XPORT Transport format. The primary intent of these commands is to assist people making submissions to the FDA, but the commands are general enough for use in transferring data between SAS and Stata.

To save the data in memory in the FDA format, type

. fdasave filename

although sometimes you will want to type

. fdasave filename, rename

It never hurts to specify the rename option. In any case, Stata will create filename.xpt as an XPORT file containing the data and, if needed, will also create formats.xpf -- an additional XPORT file -- containing the value-label definitions. These files can be easily read into SAS.

To read a SAS XPORT Transport file into Stata, type

. fdause filename

Stata will read into memory the XPORT file filename.xpt containing the data and, if available, will also read the value-label definitions stored in formats.xpf or FORMATS.xpf.

fdadescribe describes the contents of a SAS XPORT Transport file. The display is similar to that produced by describe, as is the syntax:

. fdadescribe filename

If filename is specified without an extension, .xpt is assumed.

Options for fdasave

+------+ ----+ Main +-------------------------------------------------------------

rename specifies that fdasave may rename variables and value labels to meet the SAS XPORT restrictions, which are that names be no more than eight characters long and that there be no distinction between uppercase and lowercase letters.

We recommend specifying the rename option. If this option is specified, any name violating the restrictions is changed to a different but related name in the file. The name changes are listed. The new names are used only in the file; the names of the variables and value labels in memory remain unchanged.

If rename is not specified and one or more names violate the XPORT restrictions, an error message will be issued and no file will be saved. The alternative to the rename option is that you can rename variables yourself with the rename command:

. rename mylongvariablename myname

See [D] rename. Renaming value labels yourself is more difficult. The easiest way to rename value labels is to use label save, edit the resulting file to change the name, execute the file by using do, and reassign the new value label to the appropriate variables by using label values:

. label save mylongvaluelabel using myfile.do . doedit myfile.do (change mylongvaluelabel to, say, mlvlab) . do myfile.do . label values myvar mlvlab

See [D] label and [R] do for more information about renaming value labels.

replace permits fdasave to overwrite existing filename.xpt, formats.xpf, and filename.sas files.

vallabfile(xpf|sascode|both|none) specifies whether and how value labels are to be stored. SAS XPORT Transport files do not really have value labels. In preparing datasets for submission to the FDA, value-label definitions should be provided in one of two ways:

1. In an additional SAS XPORT Transport file whose data contain the value-label definitions

2. In a SAS command file that will create the value labels

fdasave can create either or both of these files.

vallabfile(xpf), the default, specifies that value labels be written into a separate SAS XPORT Transport file named formats.xpf. Thus fdasave creates two files: filename.xpt, containing the data, and formats.xpf, containing the value labels. No formats.xpf file is created if there are no value labels.

SAS users can easily use the resulting .xpt and .xpf XPORT files. See http://www.sas.com/govedu/fda/macro.html for SAS-provided macros for reading the XPORT files. The SAS macro fromexp() reads the XPORT files into SAS. The SAS macro toexp() creates XPORT files. When obtaining the macros, remember to save the macros at SAS's web page as a plain-text file and to remove the examples at the bottom.

If the SAS macro file is saved as C:\project\macros.mac and the files mydat.xpt and formats.xpf created by fdasave are in C:\project\, the following SAS commands would create the corresponding SAS dataset and format library and list the data:

+------------------- SAS commands --------------------+ | %include "C:\project\macros.mac" ; | | %fromexp(C:\project, C:\project) ; | | libname library 'C:\project' ; | | data _null_ ; set library.mydat ; put _all_ ; run ; | | proc print data = library.mydat ; | | quit ; | +-----------------------------------------------------+

vallabfile(sascode) specifies that the value labels be written into a SAS command file, filename.sas, containing SAS proc format and related commands. Thus fdasave creates two files: filename.xpt, containing the data, and filename.sas, containing the value labels. SAS users may wish to edit the resulting filename.sas file to change the "libname datapath" and "libname xptfile xport" lines at the top to correspond with the location that they desire. fdasave sets the location to the current working directory at the time fdasave was issued. No .sas file will be created if there are no value labels.

vallabfile(both) specifies that both the actions described above be taken and that three files be created: filename.xpt, containing the data; formats.xpf, containing the value labels in XPORT format; and filename.sas, containing the value labels in SAS command-file format.

vallabfile(none) specifies that value-label definitions not be saved. Only one file is created: filename.xpt, which contains the data.

Options for fdause

clear permits the data to be loaded, even if there is a dataset already in memory and even if that dataset has changed since the data were last saved.

novallabels specifies that value-label definitions stored in formats.xpf or FORMATS.xpf not be looked for or loaded. By default, if variables are labeled in filename.xpt, then fdause looks for formats.xpf to obtain and load the value-label definitions. If the file is not found, Stata looks for FORMATS.xpf. If that file is not found, a warning message is issued.

fdause can use only a formats.xpf or FORMATS.xpf file to obtain value-label definitions. fdause cannot understand value-label definitions from a SAS command file.

member(mbrname) is a rarely specified option indicating which member of the .xpt file is to be loaded. It is not used much anymore, but the original XPORT definition allowed multiple datasets to be placed in one file. The member() option allows you to read these old files. You can obtain a list of member names using fdadescribe. If member() is not specified -- and it usually is not -- fdause reads the first (and usually only) member.

Option for fdadescribe

member(mbrname) is a rarely specified option indicating which member of the .xpt file is to be described. See the description of member() option for fdause directly above. If member() is not specified, all members are described, one after the other. It is rare for an XPORT file to have more than one member.

Remarks

SAS XPORT Transport format has been adopted by the U.S. Food & Drug Administration (FDA) for datasets submitted in support of new drug and device applications. For the FDA submission guidance document, see http://www.fda.gov/cder/guidance/2867fnl.pdf.

All users, of course, may use these commands to transfer data between SAS and Stata, but there are limitations in the SAS XPORT Transport format, such as the eight-character limit on the names of variables (specifying fdasave's rename option works around that). For a complete listing of limitations and issues concerning the SAS XPORT Transport format, and an explanation of how fdasave and fdause work around these limitations, see the technical appendix in [D] fdasave. For non-FDA applications, you may find it more convenient to use translation packages such as Stat/Transfer; see http://www.stata.com/products/transfer.html.

Remarks are presented under the following headings:

Saving XPORT files for transferring to SAS Determining contents of XPORT files received from SAS Using XPORT files received from SAS

Saving XPORT files for transferring to SAS

To save the current dataset in clindata.xpt and the value labels in formats.xpf, type

. fdasave clindata

To save the data as above but automatically handle renaming variable names and value labels that are too long or are case sensitive, type

. fdasave clindata, rename

To allow the replacement of any preexisting files, type

. fdasave clindata, rename replace

To save the current dataset in clindata.xpt and the value labels in SAS command file clindata.sas and to automatically handle renaming variable and value-label names:

. fdasave clindata, rename vallab(sas)

To save the data as above but save the value labels in both formats.xpf and clindata.sas, type

. fdasave clindata, rename vallab(both)

To not save the value labels at all, thus creating only clindata.xpt, type

. fdasave clindata, rename vallab(none)

Determining contents of XPORT files received from SAS

To determine the contents of drugdata.xpt, you might type

. fdadescribe drugdata

Using XPORT files received from SAS

To read data from drugdata.xpt and obtain value labels from formats.xpf (or FORMATS.xpf), if the file exists, you would type

. fdause drugdata

To read the data as above and discard any data in memory, type

. fdause drugdata, clear

Saved results

fdadescribe saves the following in r():

Scalars r(N) number of observations r(k) number of variables r(size) size of data r(n_members) number of members

Macros r(members) names of members

Also see

Manual: [D] fdasave

Help: [D] describe, [D] infiling, [D] odbc, [D] outfile, [D] save


© Copyright 1996–2009 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index