To 'copy' the PDV structure of a data set, it has been advised to "reference a data set at compile time" using
if 0 then set <data-set>
For example,
data toBeCopied;
length var1 $ 4. var2 $ 4. ;
input var1 $ var2 $;
datalines;
this is
just some
fake data
;
run;
data copyPDV;
if 0 then set toBeCopied;
do var1 = 'cutoff' ;
do var2 = 'words';
output;
end;
end;
run;
When you run this, however, the following NOTE appears in the log:
NOTE: DATA STEP stopped due to looping.
This is because the data step never reaches the EOF marker and gets stuck in an infinite loop, as explained in Data Set Looping. (It turns out the DATA step recognizes this and terminates the loop, hence the NOTE in the log).
It seems like usage of the if 0 then set <data-set>
statement is a longstanding practice, dating as far back as 1987. Although it seems hacky to me, I can't think of another way to produce the same result (i.e. copying PDV structure), aside from manually restating the attribute requirements. It also strikes me as poor form to allow ERRORs, WARNINGs, and NOTEs which imply unintended program behavior to remain in the log.
Is there way to suppress this note or an altogether better method to achieve the same result (i.e. of copying the PDV structure of a data set)?
If you include a stop;
statement, as in
if 0 then do;
set toBeCopied;
stop;
end;
the NOTE still persists.
Trying to restrict the SET
to a single observation also seems to have no effect:
if 0 then set toBeCopied (obs=1);