BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ywon111
Quartz | Level 8

I have a Start date variable as a category and want to turn into a date. Have used RemoveChars to remove the strings but how to convert it to a proper date so it can be sorted correctly?

 

 

Start date Want
05/04/2021 (abc) 5/04/2021
05/04/2021 (abc) 5/04/2021

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

It would be better to fix this before it is loaded into VA using the methods already given 

View solution in original post

5 REPLIES 5
sas_it
Quartz | Level 8

Following method can be used to solve the issue :

date_n=input(substr(start_date,1,10),mmyydd10.);

format date_n date9.; 

ywon111
Quartz | Level 8
Have used the Substring operator as below but because it's a character the sorting doesn't quite work correctly as dates -

Substring('Start date'n, 1, 10)

Sorry, but I am referring to SAS VA not EG, is there a way to fix in VA?

Thanks
SASKiwi
PROC Star

It would be better to fix this before it is loaded into VA using the methods already given 

Kurt_Bremser
Super User

Data needs to be cleaned before it goes to VA. VA is for analytics, not for ETL.

And date values HAVE to be stored as such when data is imported into SAS.

Astounding
PROC Star

A simpler method:

data want;
   set have;
   want_date = input(start_date, mmdyy10.);
   format want_date mmddyys10.;
run;