Macros for SAS Application Developers
No Matches File Reference

Create a CARDS file from a SAS dataset. More...

Go to the source code of this file.

Detailed Description

Uses dataset attributes to convert all data into datalines. Running the generated file will rebuild the original dataset. Includes support for large decimals, binary data, PROCESSED_DTTM columns, and alternative encoding. If the input dataset is empty, the cards file will still be created.

Additional support to generate a random sample and max rows.


  , tgt_ds=work.class
  , cards_file= "C:\temp\"
  , showlog=NO
  , maxobs=5


  • labelling the dataset
  • explicity setting a unix LF
  • constraints / indexes etc
[in]base_dsShould be two level - eg work.blah. This is the table that is converted to a cards file.
[in]tgt_ds=Table that the generated cards file would create. Optional - if omitted, will be same as BASE_DS.
[out]cards_file=("%sysfunc(pathname(work))/") Location in which to write the (.sas) cards file
[in]maxobs=(max) To limit output to the first maxobs observations, enter an integer here.
[in]random_sample=(NO) Set to YES to generate a random sample of data. Can be quite slow.
[in]showlog=(YES) Whether to show generated cards file in the SAS log. Valid values:
  • YES
  • NO
[in]outencoding=Provide encoding value for file statement (eg utf-8)
[in]append=(NO) If NO then will rebuild the cards file if it already exists, otherwise will append to it. Used by the macro.

Related Macros

Allan Bowe

Definition in file