Don't worry if you don't remember every detail after you have read it. Read the whole thing! It's long and complicated, but you will never become proficient at working with dates and times unless you plough through it. But if this sort of thing will pop up again in your line of work, you should invest time in running -help datetime- and then clicking on the blue link to the PDF manual near the top of that page. If dealing with dates and times is not something you will be doing in the future, it is fine to just appropriate this code and use it. If you omit it, your datetime variable will be incorrect. You might also take a look at the user-contributed numdate (SSC install numdate)Ĭode: gen double datetime = mdyhms(month, day, year, hr-1, 0, 0)įormat datetime %tcN.B.: The -double- is absolutely critical. +-+For help with adding the hour to the date, see add hours to date variable Variable name type format label variable label Gen date3 = date // note that date3 is not formatted as a date. Gen date = mdy(month, day, year) // this is what actually combines the 3 variables into a single date Code: * This assumes month, day, & year are *numeric* variables
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |