I am trying to work with dates - specifically getting the mean interval in days between two dates. But I am having difficulty getting the results displayed in "days"
I import my data from excel containing ID and and five date-variables
Code:
. import excel DCCG_oprenset_aktuel.xlsx, firstrow clear sheet(R2.2) (60 vars, 1,078 obs) . . gen hgb_0_date=date(samlethgb_datotættestpådiagn,"DMY") (283 missing values generated) . format %td hgb_0_date . gen hgb_1_date=date(hgb_datotættestpåindenoper,"DMY") (246 missing values generated) . format %td hgb_1_date . . gen ferritin_0_date=date(samletferritin_datotættestpå,"DMY") (382 missing values generated) . format %td ferritin_0_date . gen ferritin_1_date=date(ferritin_datotættestpåinden,"DMY") (356 missing values generated) . format %td ferritin_1_date . . rename Op_dato op_date
Code:
. describe hgb_0_date hgb_1_date ferritin_0_date ferritin_1_date op_date storage display value variable name type format label variable label --------------------------------------------------------------------------------------------------------------- hgb_0_date float %td hgb_1_date float %td ferritin_0_date float %td ferritin_1_date float %td op_date int %td Op_dato . . gen hgb_dif = op_date - hgb_1_date if(hgb_1_date!=hgb_0_date) (475 missing values generated) . gen fer_dif = op_date - ferritin_1_date if(ferritin_1_date!=ferritin_0_date) (953 missing values generated) . sum hgb_dif fer_dif Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- hgb_dif | 603 6.903814 17.94058 0 378 fer_dif | 125 3749.624 12064.02 0 43268
Magnus
0 Response to Substracting dates to get days-between
Post a Comment