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

I imported an excel file that has two date columns (B,C). I then created a computed column that references two datastes. One, that I imported and another one, dataset B that has a date column of D).If the dateB in dataset A equals a date D in dataset B then I want dateC from dataset A to populate.  It does, but it populates as a string (20820)  instead of 01MAR2017.  If I look at datasetA after importing it shows up as 01MAR2017 and if I look at the dates in datasetB they also show up as 01MAR2017.  Why is the computed column going to a string format? 

In the computed column when I do the case statement it shows t1.'dateB'n  which I assumed was the reason but when I try to type in 't1.'dateB'd it errors.

Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

 t1.'dateB'n - this has nothing to do with it.  '...'n refers to a variable using named literals (i.e. doesn't conform to SAS standards).

20820 - this is the numeric representation of a date.  Dates in SAS a numbers of days since a certain date, to display them in a date format, you would need to apply a date format for instance date9.

As for it being read in a character, that doesn't sound right as the date number is there, I assume you should just be able to apply a format to that variable.

 

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

 t1.'dateB'n - this has nothing to do with it.  '...'n refers to a variable using named literals (i.e. doesn't conform to SAS standards).

20820 - this is the numeric representation of a date.  Dates in SAS a numbers of days since a certain date, to display them in a date format, you would need to apply a date format for instance date9.

As for it being read in a character, that doesn't sound right as the date number is there, I assume you should just be able to apply a format to that variable.

 

mmagnuson
Quartz | Level 8

The format worked. For some reason I picked a different date format and still spit out numbers but when I clicked Date9. it came out in the excel sheet as a date.

Thanks for the help!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1239 views
  • 0 likes
  • 2 in conversation