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

Hi,

Below is an example of the data I have.

 

Both A and B must be character types. 

 

I just want to assign a date format to column A so that I get output as column B. 

 

how can I do this efficiently without any warnings? Please advise. 

 

A B
20150107 2015/01/07
20150207 2015/02/07
2015 2015
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Is this what you want?

If the string in A can be interpretted as YYYYMMDD then make B have the same date printed with slash delimiters.  Otherwise just copy A to B.

data want;
  set have;
  date = input(a,??yymmdd8.);
  if not missing(date) then b=put(date,yymmdds10.);
  else b=a;
  drop date;
run;

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Is this what you want?

If the string in A can be interpretted as YYYYMMDD then make B have the same date printed with slash delimiters.  Otherwise just copy A to B.

data want;
  set have;
  date = input(a,??yymmdd8.);
  if not missing(date) then b=put(date,yymmdds10.);
  else b=a;
  drop date;
run;

 

bharath86
Obsidian | Level 7

Thank you sir.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 689 views
  • 0 likes
  • 2 in conversation