How to store a SAS numeric date field to a new dataset with a date type

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

How to store a SAS numeric date field to a new dataset with a date type

 

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.

 


Accepted Solutions
Solution
‎03-12-2018 11:36 AM
Super User
Posts: 23,337

Re: How to store a SAS numeric date field to a new dataset with a date type

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


All Replies
Solution
‎03-12-2018 11:36 AM
Super User
Posts: 23,337

Re: How to store a SAS numeric date field to a new dataset with a date type

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.;
Occasional Contributor
Posts: 17

Re: How to store a SAS numeric date field to a new dataset with a date type

It worked! Thank you so much!

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 104 views
  • 1 like
  • 2 in conversation