I have an empty dataset A with 2 variables date_num and date_char It has been created as:- data a;
attrib date_num length=8. format=date9.
date_char length=$200.
;
run; I have another dataset E having 2 variables origdt (original date - numeric) and id(character) variable. The dataset E is:- ID ORIGDT
520-03-08 17-Dec-15
330-03-02 19-May-15
110-42-01
330-09-02
380-04-21 5-Sep-16
380-09-07
110-09-01
610-05-03 12-May-15
110-34-10 7-Nov-16
110-11-01 6-Feb-17 The datasset E can be created as :- data E;
input ID$1-9 ORIGDT:Date9.;
format ORIGDT DATE9.;
datalines;
520-03-08 17-Dec-15
330-03-02 19-May-15
110-42-01 .
330-09-02 .
380-04-21 5-Sep-16
380-09-07 .
110-09-01 .
610-05-03 12-May-15
110-34-10 7-Nov-16
110-11-01 6-Feb-17
run; I have created a new dataset as under:- data temp;
set a(obs=0) e;
if not missing(origdt) then date_num=origdt;
if not missing(origdt) then date_char=put(origdt,DATE9.);
run; The problem is that for variable date_num/date_char, even for values which have missing origdt, the value of previous observation is retained and populated, unless I explicitly put an else statement. Please Help !!!!! To all those who are saying that do not include 'A' dataset, the reason why it has been set is because, it's the metadata. It forms the basis for newly created variables. It essentially contains their formats, informats, label, length (variable attributes), etc... Also I know that variables are being retained, but I need a further explanation. This is a rare situation in which if an 'if statement' is used alongwith the set statement, the variables for which even if the condition is not true are being populated.(Check attached file) However if the datasets are simply set, even if there is a missing variable in they remain as is.
... View more