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

 

Good Morning,

 

I am creating a new variable that will store the end of the month data of my "date of service " field. I am using the formula below:

 

eom_var= intnx('month',serv_from_date,0,'e');

eom_date = put(eom_var, mmddyy10.);

 

The variable created in the new dataset has a character type. How do I convert this new variable to date field type so I can compare with another dataset whose date variables are all date type.

 

I am beginner in SA and would greatly appreciate your assistance. Thank you in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

eom_var= intnx('month',serv_from_date,0,'e');

eom_date = put(eom_var, mmddyy10.);  <- PUT converts the variable to a character. Remove this line.

 

Instead, add a format to your date so you can see it properly.

 

eom_date = intnx('month', serv_from_date, 0, 'e');
format eom_date yymmdd10.;

View solution in original post

2 REPLIES 2
Reeza
Super User

eom_var= intnx('month',serv_from_date,0,'e');

eom_date = put(eom_var, mmddyy10.);  <- PUT converts the variable to a character. Remove this line.

 

Instead, add a format to your date so you can see it properly.

 

eom_date = intnx('month', serv_from_date, 0, 'e');
format eom_date yymmdd10.;
lmtamina
Obsidian | Level 7

It worked! Thank you so much!

 

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!

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.

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
  • 2 replies
  • 316 views
  • 1 like
  • 2 in conversation