![]() Since bday is a string variable, you cannot do any kind of date computations with it until you make aĭate variable from it. Using the list command, you can see that the date information has been read correctly into ![]() ![]() You can read these data by typing: infix str name 1-4 str bday 6-17 using dates1.raw (4 observations read) You might have the following date data in your raw data file. Them as character strings, and then later convert them into a Stata date The trick to inputting dates in Stata is to forget they are dates, and treat Gen baddate2 = cond(baddate < 1e7, "0" + strofreal(baddate, "%8.0f"), strofreal(baddate, "%8.This module will show how to use date variables, date functions, and date display formats in Stata.Ĭonverting dates from raw data using the "date()" function I create a data example first, because you didn't give one. There are several ways to do it, but this is one that works. If you have such dates, then the conversion is something like this. summarize will be measured in millions, not thousands. You can tell if you have such dates quite easily as for recent dates their mean from e.g. If (horrors) your daily dates are integers like 101192022 then you need to convert to Stata daily dates to use age(). There is no need to hold daily dates as long. This was added on 5 November 2020 and so is available in properly updated Stata 16 and in Stata 17 (upwards, if you are reading this some while after it was posted). But in recent versions of Stata, there is a function age() which does that directly, and is smart about leap years.In some fields, a rough average of 365.25 days per year is considered close enough. If your dates are proper Stata daily dates, then you need to subtract one from the other, and convert to years, rounding down.Number of observations (_N) was 0, now 1. Giving us an example of your data would have helped. Ipodate long %td Company Initial Public Offering Date Spcsrc str4 %4s S&P Quality Ranking - Current Sic str4 %4s Standard Industry Classification Code Prcc_c double %18.0g Price Close - Annual - Calendarīusdesc str2000 %2000s S&P Business Description Xsga double %18.0g Selling, General and Administrative ExpenseĬostat str2 %2s Active/Inactive Status Marker Xrd double %18.0g Research and Development Expense Txditc double %18.0g Deferred Taxes and Investment Tax Credit Tlcf double %18.0g Tax Loss Carry Forward Pstkl double %18.0g Preferred Stock - Liquidating Value Ppent double %18.0g Property, Plant and Equipment - Total (Net) Oibdp double %18.0g Operating Income Before Depreciation Itcb double %18.0g Investment Tax Credit (Balance Sheet) Intan double %18.0g Intangible Assets - Total Can someone help me out with this? Any help is greatly appreciated!Ĭonsol str2 %2s Level of Consolidation - Company Annual DescriptorĬsho double %18.0g Common Shares Outstandingĭlc double %18.0g Debt in Current Liabilities - Totalĭltt double %18.0g Long-Term Debt - Totalĭp double %18.0g Depreciation and Amortization In this way, I want to obtain the number of years a firm is publicly traded, which I need for my thesis. I want to take the current date, measured as DDMMYYYY with Type 'Long', and subtract the IPO Date, measured in the same way. I want to calculate the amount of years a company is publicly traded. As such, I hope someone could help me here. I have an issue that might seem easy, but I find it surprisingly hard to solve. Other users who have found the question cross-posted are encouraged to share the links as a reply as well. If you've asked a question, let people know where else you asked the question and what your solution(s) were! When you post a question on another platform, include those links in your questions or as a reply (if it's Discord, just mention it).See the sticked "READ ME: How to best ask for help in /r/Stata" post on how to comment here if all else fails. Make sure to include the word "Stata" in your search query. Perform a web search for your question prior to posting here. Stata's online community has been active for many years and many questions and solutions are documented on StataList, which are highly indexed on contemporary search engines (e.g., Google). Stata has extensive and complete documentation you can read before posting here (and you can type help followed by the command name in console to see it, e.g. This is not a place to find Stata tutoring. Do not request that the /r/Stata community do your homework for you. Assume good faith questions and comments. Be nice when posting or commenting to a post.The Code Block on Discord (run by Asjad Naqvi of The Stata Guide).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |