Hello!
I am a student just started using Stata. I experience two issues trying to use Stata. Hopefully someone can help me
I have data for different companies which I have classified R&D intensive or not (given the sic code) through an new variable. So each company is either R&D intensive or non R&D intensive. Not every company has an observation in different ways: not always is there an entry for xrd (.) and not every company has observations for all the years from 1987-1997. It looks like this:
(please see Data Stata.jpg)
I want to draw a graph (i) for the sum of the R&D spendings for all companies (let’s say from 1987 to 1997) and (ii) a graph for the sum just for companies which are classified non R&D intensive. The missing values can be handled as “0”. Also that for some years, a certain company is not always included (there are i.e. just values for 1992-1995)- that does not matter. The gvkey and company name do not matter as well.
Simple as that, no matter what I try, I am not able to create such a figure. It should look like this (just an example plotted with excel):
(please see Graph Stata.jpg)
I tried to use:
*create new var for plotting graph just non-R&D intensive companies*
egen totalrd_nrd = total (industry=="Non R&D Intensive"), by(year)
It puts the sum of the R&D Spendings into all the observations. When I then use
graph twoway line totalrd_nrd year
it is a huge amount of points connected where I just want a few points connected (the sum of the spendings over the years 1987 to 1997, so eleven points connected which should give the graph. and then the second graph, also having the eleven points [sum for each year] connected).
The second issue I got, is to fit a geometric trend to the real data on R&D Spendings from 1982 to 1995 for the as R&D intensive classified companies. It is the same data: so I wanted to use “R&D intensive” companies and “1982 to 1995”. But no matter what I try, I am not able to calculate and display a trend. Any ideas would be really helpful!
Thanks to all of you!
I am a student just started using Stata. I experience two issues trying to use Stata. Hopefully someone can help me

I have data for different companies which I have classified R&D intensive or not (given the sic code) through an new variable. So each company is either R&D intensive or non R&D intensive. Not every company has an observation in different ways: not always is there an entry for xrd (.) and not every company has observations for all the years from 1987-1997. It looks like this:
(please see Data Stata.jpg)
I want to draw a graph (i) for the sum of the R&D spendings for all companies (let’s say from 1987 to 1997) and (ii) a graph for the sum just for companies which are classified non R&D intensive. The missing values can be handled as “0”. Also that for some years, a certain company is not always included (there are i.e. just values for 1992-1995)- that does not matter. The gvkey and company name do not matter as well.
Simple as that, no matter what I try, I am not able to create such a figure. It should look like this (just an example plotted with excel):
(please see Graph Stata.jpg)
I tried to use:
*create new var for plotting graph just non-R&D intensive companies*
egen totalrd_nrd = total (industry=="Non R&D Intensive"), by(year)
It puts the sum of the R&D Spendings into all the observations. When I then use
graph twoway line totalrd_nrd year
it is a huge amount of points connected where I just want a few points connected (the sum of the spendings over the years 1987 to 1997, so eleven points connected which should give the graph. and then the second graph, also having the eleven points [sum for each year] connected).
The second issue I got, is to fit a geometric trend to the real data on R&D Spendings from 1982 to 1995 for the as R&D intensive classified companies. It is the same data: so I wanted to use “R&D intensive” companies and “1982 to 1995”. But no matter what I try, I am not able to calculate and display a trend. Any ideas would be really helpful!
Thanks to all of you!
Comment