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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.