BookmarkSubscribeRSS Feed
Ravikumarkummari
Quartz | Level 8

hi all,

i have the dataset with variables id name joining date and salary

the birthdate is in the format date9.

now i have to read birthday only year i am trying with substr function but not getting the result.

can some one help me.

i tried as

x=substr("join_date"d, length("join_date"d)-3,4);

Is it correct?

4 REPLIES 4
Reeza
Super User

Is your join date variable a character or number/sas date. If its a number then Kurts solution is correct. If its a char yours is close but need to remove quotes and d from around join_date variable. Its not a good method because what if the date is shorter in some circumstances though.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

I agree with Reeza on the character.  If its a date then you would normally have some kind of delimiter between day/month/year.  Easier to check that:

for date_variable="01/JAN/2000"

Year=scan(date_variable,3,"/");

Should set year="2000" as its the third part.

Community_Help
SAS Employee

Hi there, I'm moving this from the "about Communities on SAS" space to the SAS Procedures space just so that these answers are visible to others in that area. Thanks!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 882 views
  • 0 likes
  • 5 in conversation