Hello,
I am needing to convert the "DATEINT" variable into a numeric, date format (mmddyy10.) however I am having trouble doing so.
DATA WAVE5_8LD;
SET WAVE5_8L;
NDATEINT= INPUT(DATEINT,DDMMYY10.);
FORMAT DATEINT MMDDYY10.;
RUN;
I want to be able to format "DATEINT" to match how variable "dod" is so that I can perform an analysis on them. This is from a pre-existing dataset.
It seems that you are using the wrong informat, ddmmyy requires the month to be a number from 1 to 12, not the abbreviated month name. Unfortunately you have not posted the data in usable form, so i won't provide code. Maybe reading those dates is possible with date9-informat after applying compress-function to dateint removing the hyphens.
attached is my dataset
Read like this:
data test;
infile '/folders/myfolders/WAVE5_8L.csv' dlm=',' dsd firstobs=2;
input
q_no $
isdead
agedie
dod :mmddyy10.
YSMOKE
wave
DATEINT :date11.
UM
UG
TOTMMSE
TOTADL
sfrailcatb
sex
nfrac
marstat
ll
lcancr
khyper
jstrok
icardi
cesdtot
bmi
age
mdiab
;
format dod dateint yymmdd10.;
run;
SAS dates are counts of days, so you only need a simple subtraction.
You can apply the DATE11. format directly:
data test;
dateint = "11-Aug-2020";
datenum = input(dateint,date11.);
format datenum yymmdd10.;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.