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

I need to combine cc , yy, mm, dd  numeric variable into 1 variable.   mm can be input as 3 so i need to make it 03 first and then merge into one variable.

 

I need to do this with all variables.

 

Not sure how to do any help please.

 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
sgarg
Fluorite | Level 6

Thankyou Guys for replay and great help...

 

I wrote the code like below and it worked.  THANKS AGAIN!

 

ELIG_CERT_EFF_DATE =mdy(mm,dd,100*cc+yy);
   format ELIG_CERT_EFF_DATE mmddyyn8.; 

View solution in original post

4 REPLIES 4
mkeintz
PROC Star

Since they are numeric, not character, variables, it doesn't matter that some mm, some dd, or some yy are single digits (I presume cc is 19 or 20).  You'll use numeric operations and numeric function on them.

 

  my_date=mdy(mm,dd,100*cc+yy);

  format my_date date9.;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Reeza
Super User

@sgarg wrote:

I need to combine cc , yy, mm, dd  numeric variable into 1 variable.  

OK. What do you want as the output in that variable?

 


@sgarg wrote:

mm can be input as 3 so i need to make it 03 first and then merge into one variable.

 

 


Show what you have and what you need as output, explicitly. 

 


@sgarg wrote:

 

I need to do this with all variables.

 

 


You've indicated three variables, how many variables do you have? What have you tried so far? 

Do you instead mean you need to do this for all rows/records or for multiple different day/month/year variables?

 

 

sgarg
Fluorite | Level 6

Thankyou Guys for replay and great help...

 

I wrote the code like below and it worked.  THANKS AGAIN!

 

ELIG_CERT_EFF_DATE =mdy(mm,dd,100*cc+yy);
   format ELIG_CERT_EFF_DATE mmddyyn8.; 

Reeza
Super User

@sgarg please mark @mkeintz answer as correct, because he posted the correct solution. 

 

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