Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_ds2cards.sas 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.

Usage:

%mp_ds2cards(sashelp.class
  , tgt_ds=work.class
  , cards_file= "C:\temp\class.sas"
  , showlog=NO
  , maxobs=5
)

TODO:

  • labelling the dataset
  • explicity setting a unix LF
  • constraints / indexes etc
Parameters
[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))/cardgen.sas") 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 mp_lib2cards.sas macro.

Related Macros

Version
9.2
Author
Allan Bowe

Definition in file mp_ds2cards.sas.