Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73412

convert date to year, month, day for several variables with different name formats

$
0
0
Hi All,

I have 10 different variables with the word "date" in their name. The names have two parts, word "date" and a unique part.But the order of these two parts is different. For example, dateinposition and hiredate. I want to split all of these dates into their year, month, and day and make the new variables' names to the unique part+year, unique part+month, and uniquepart+day

All these variables are string and in yyyy-mm-dd format.

My new variables would be:

inpositionyear inpositionmonth inpositionday hireyear hiremonth hireday

I know how to use split command for one variable, but I don't know how to use a loop for all variables when the names have different formats.

I really appreciate your help.

Viewing all articles
Browse latest Browse all 73412

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>