I have a SAS data set with a text field customer_id
and a numeric field month
in the format YYYYMM
. I'm creating a view of these data, and I want to convert the data to a standard SAS date that will (hopefully) be preserved on export. For example:
proc sql;
create view my_view as
select customer_id, month from raw_dataset;
quit;
proc export data = my_view
file = "out.dta"
dbms = stata replace;
quit;
Looking at the date documentation, it looks like the number is in the form (although not the data type) YYMMN.
, but I want it in a format that SAS can work with as a date, not just a number e.g. with proc expand
.
I've seen a lot of questions using combinations of put
and datepart
, but since I don't want the variable as a string and don't already have a datetime variable, I'm not sure how to apply those.
How do I convert this column to a SAS date data type when I run this SQL query?