BookmarkSubscribeRSS Feed
harrylui
Obsidian | Level 7

Hi Everyone,

 

The  below table is my portion of data set, What i want to do is to translate these sql codes to sas but it is quite diffcult to me.

 

can anyone help me with this. thanks a lot!!! My Data is char form

 

 

Julianday(SUBSTR(PTF.Premium_To_Date,1,4) || '-' || SUBSTR(PTF.Premium_To_Date,5,2) || '-01') - Julianday(SUBSTR(PTF.Premium_From_Date,1,4) || '-' || SUBSTR(PTF.Premium_From_Date,5,2) || '-01') > 180

 

 Premium     Premium

FromDate   ToDate

2013010120130131
2013010120130131
2013010120130131
2013010120130131
2013010120130131
2013010120130131
2013010120130131
2013010120130131
2013010120130131
3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Could you try below code, if you consider you have a dataset as have and you want to generate dataset want

 

data want;
set have;
Julianday(SUBSTR(Premium_To_Date,1,4) || '-' || SUBSTR(Premium_To_Date,5,2) || '-01') - Julianday(SUBSTR(Premium_From_Date,1,4) || '-' || SUBSTR(Premium_From_Date,5,2) || '-01') > 180;
run;
Thanks,
Jag
harrylui
Obsidian | Level 7

i am using studio version and there is no JULIANDAY Function, thx

 

andreas_lds
Jade | Level 19

Please post data in a usable form and show what you expect as result.

 

Steps to solve the problem

  • use input-function with the appropriate informat to convert the char-dates to sas-dates
  • use intck to calculate the difference

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 3 replies
  • 1281 views
  • 0 likes
  • 3 in conversation