HI,
I have 4 data sets containing date variables:
Table1
date is in date format (21-Mar-2017)
table 2
date is in character (21 Mar 2017)
table3
date is in character (21 mar 2017)
table4
date is in date format (21-mar-2017)
am trying to change the char to date format but it displays nil values. Please help. I need to merge the 4 tables.
Hi Have modified my previous query:
data test1(drop = PastDueSince);
set Past_Due_Actual_Days2;
format _PastDueSince date9.;
_PastDueSince = input(trim(PastDueSince),date9.);
PastDueSince = PastDueSince;
rename _PastDueSince=PastDueSince;
run;
Works like charm!!!
Please supply
- information about the date variables in all datasets with type, length and assigned format
- the code you already tried for those variables
- example values for numeric variables, raw without any format (use best.)
Please read my post again and assist me in helping you. Right now I don't know a jota more than before.
data Magellan3;
set Magellan2;
PastDueSince=input(PastDueSince,mmddyy16.);
run;
DATA Past_Due_Actual_Days2;
/*format PastDueSince date9.;*/
SET Past_Due_Actual_Days;
/*PastDueSince = f20;*/
PastDueSince =inputput(F20,f8.0),yymmdd.);
/*PastDueSince = PastDueSince - 21916;*/
RUN;
You are using wrong formats everywhere.
mmddyy16 is not informat for 17-Jun-2016 nor is yymmdd. You need to use date11.
data mylasr.test1;
Date1=input("15-jul-2015", date11.);
output;
run;
This:
data Magellan3;
set Magellan2;
PastDueSince=input(PastDueSince,mmddyy16.);
run;
can never work. You cannot change the type of a variable.
Hi Have modified my previous query:
data test1(drop = PastDueSince);
set Past_Due_Actual_Days2;
format _PastDueSince date9.;
_PastDueSince = input(trim(PastDueSince),date9.);
PastDueSince = PastDueSince;
rename _PastDueSince=PastDueSince;
run;
Works like charm!!!
For clarity's sake, I'd write it a little differently:
data test1 (
drop=_PastDueSince
);
set Past_Due_Actual_Days2 (
rename=(PastDueSince=_PastDueSince)
);
format PastDueSince date9.;
PastDueSince = input(trim(_PastDueSince),date9.);
run;
This makes it more readable with regards to what is converted to what.
Please refer to this post:
On how to create test data which shows what your data looks like, both data wise, but also structurally. Its also a good idea to post code you have written.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.