Last active
October 12, 2021 17:35
-
-
Save szimmer/0604dcf0818fb18b1255ca1ac76be786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data ds1; | |
length id dob age 8.; | |
format dob mmddyy10.; | |
informat dob ANYDTDTE.; | |
input id dob age; | |
cards; | |
1 03292007 . | |
2 06262006 . | |
3 . 15 | |
4 . . | |
5 07252008 14 | |
6 08242007 . | |
; | |
run; | |
data ds2; | |
length id dob 8.; | |
format dob mmddyy10.; | |
informat dob ANYDTDTE.; | |
input id dob ; | |
cards; | |
10 03082009 | |
11 . | |
12 04102007 | |
; | |
run; | |
data ds_comb; | |
set ds1 (in=a) ds2; | |
if a then DS=1; else DS=2; | |
if not missing(dob) then age=floor(yrdif(dob, "24MAR21"d)); | |
run; | |
ods listing; | |
proc print data=ds_comb noobs; | |
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id dob age DS | |
1 03/29/2007 13 1 | |
2 06/26/2006 14 1 | |
3 . 15 1 | |
4 . . 1 | |
5 07/25/2008 12 1 | |
6 08/24/2007 13 1 | |
10 03/08/2009 12 2 | |
11 . 12 2 | |
12 04/10/2007 13 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why does ID=11 have an age of 12 retained from the previous record?