I have some source columns like(For Eg.)
Process_Date
Jun 01 2013 6.40pm
Feb 14 2012 7.25am
Mar 28 2011 3.40pm
I need to validate this column,whether tis date is correct date or not.
Then,I need to load this date column to target as (DD/MM/YYYY). like
01/06/2013
14/02/2012
28/03/2011
How to do this in SAS DI Studio?Kindly help me on this.
Hi Helann,
Please try ....
data have ;
input test_date $20. ;
cards;
Jun 01 2013 6.40pm
Feb 14 2012 7.25am
Mar 28 2011 3.40pm
;run;
data want (drop = a b c d) ;
set have;
a = compress(upcase(substr(test_date,1,3)));
b = substr(test_date,5,2);
c = substr(test_date,8,4);
if a = 'JAN' then d = 1;
else if a = 'FEB' then d = 2;
else if a = 'MAR' then d = 3;
else if a = 'APR' then d = 4;
else if a = 'MAY' then d = 5;
else if a = 'JUN' then d = 6;
else if a = 'JUL' then d = 7;
else if a = 'AUG' then d = 8;
else if a = 'SEP' then d = 9;
else if a = 'OCT' then d = 10;
else if a = 'NOV' then d = 11;
else if a = 'DEC' then d = 12;
Final_date = mdy(d,b,c);
format Final_date ddmmyy10.;
Run;
data have ; input test_date & ?? anydtdtm. ; date=datepart(test_date); format date ddmmyy.; cards; Jun 01 2013 6.40pm Feb 14 2012 7.25am Mar 28 2011 3.40pm ;run;
Ksharp
Good one Shap, I was expecting for a best Solution... Thanks.!!
Assuming you start with an external file then you could define the Process_Date column with informat "anydtdte." and format "ddmmyy10." in the "external file" object.
Then use a "File Reader" and then a "Data Validation" transformation.
In the "Data Validation" transformation check for missings. All source values for "Process_Date" (the text strings) which couldn't be converted to a SAS date value will be missing.
Thanks all for ur reply.
I am facing an issue in all client machines.So I cant able to run any job.
I will try tis ,once the issue is resolved.
Can u pls help me in resolving this issue.
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.