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

Hi all,

 

I've read a lot of other posts and can't seem to figure out what I am doing wrong.

 

In one file I have a date that is YYMMDD8. and shows a calendar next to it. The type is numeric.

 

In another file I have a date that is DDFEBYYYY. It is a numeric date9, and says its a length 8.

 

 

 

I tried the following code to transform the date 9 to the 8, but it's still not right. Now one is showing a calendar next to it and the other isn't. The join fails.

Period_End1=PUT(period_end_date_num, yymmddn8.);
Period_End = input(Period_End1, 8.);

 

I know I'm missing something obviously simple, or I can do this is a much easier way... like convert the date 9 to a date 8? Frustrated at this point. Thank you for the help!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

 

 

In one file I have a date that is YYMMDD8. and shows a calendar next to it. The type is numeric.

 

In another file I have a date that is DDFEBYYYY. It is a numeric date9, and says its a length 8.

 



The thing we need to know is the format for each variable and whether it is character or numeric. The length is irrelevant. Show us a screen capture of what you see.

 
 
 
 
--
Paige Miller

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Hi @anweinbe  Here is a way to approach this kind of problem

 

1. Verify the type of the join keys in both datasets

2. If you notice a type mismatch, just convert one of the key to numeric or character depending upon the value. If it is date, you are better off keeping both as numeric.

3. So look for which one of the date is char, and convert the char_date using a compatible informat i.e if ddmmmyyyy, the informat is date9.

4. With the above 3 done, the JOIN becomes straight forward

 

HTH

 

PS assuming both are numeric in your sample, do not bother any conversion as those dates are mere integers and that makes a case of a straight forward join anyway

PaigeMiller
Diamond | Level 26

 

 

In one file I have a date that is YYMMDD8. and shows a calendar next to it. The type is numeric.

 

In another file I have a date that is DDFEBYYYY. It is a numeric date9, and says its a length 8.

 



The thing we need to know is the format for each variable and whether it is character or numeric. The length is irrelevant. Show us a screen capture of what you see.

 
 
 
 
--
Paige Miller
anweinbe
Quartz | Level 8

I didn't need to transform anything sheesh! I thought because one was 8 and one was 9 they wouldn't work! All that time for nothing. At least I learned something.

 

Thank you Paige!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 817 views
  • 0 likes
  • 3 in conversation