data s1 ;
name=22122018 ;
run;
proc sql ;
select input(put(name,best.),ddmmyy10.) as date format=ddmmyyd10. from s1 ;
quit;
if run above program it gives 22-12-2020 but i want as it is date
data s1 ;
name=22122018 ;
run;
proc sql ;
select input(put(name,best. -l),ddmmyy10.) as date format=ddmmyyd10. from s1 ;
quit;
Your code would keep lead blanks .
Like : ___20122018 .So when you input() it ,your code only read the first 10 characters ___201220, that lead to wrong date.
if you use put(x,best. -L) would get rid of lead blanks and you would get:
20122018 and input() will correctly read it .
So you have a 8-digit number that should be a date. Convert it with
date = input(put(name,z8.),ddmmyy8.);
The z8. format makes sure that leading zeroes are not dropped.
What format you assign to the new variable depends on how you want it displayed.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.