Making an empty dataset in SAS

The code below shows you how to make an empty dataset in SAS.
If you omit the if-sentence  and below, then you will get an empty row in the dataset.

This can also be done a bit easier in SQL.

3 thoughts on “Making an empty dataset in SAS”

  1. Ummm, wouldn’t this code be more straightforward?

    data StatusTable;
    length Dataset $100 Message $150 Status $10;

    At the top of the processing loop, SAS creates the empty dataset, ready to be written to, and automatically fills the PDV with missing values. The STOP statement keeps SAS from writing anything into the dataset, leaving it empty.

  2. You can use a WHERE that is always false to limit the output to zero observations:

    data StatusTable(WHERE=(1=0));
    length Dataset $100 Message $150 Status $10;
    call missing(Dataset, Message, Status);

Leave a Reply

Your email address will not be published. Required fields are marked *