*Stata tutorial do-file *You can write comments like these by placing a star (*) before your sentence *For this example, I will use Stata's webuse function to load a panel dataset. When loading datasets of your own, you can do the exact same thing, except leave the "web" part out, and just write "use". First start by clearing Stata from any old data though clear all *Then, remember to set your working directory (using the command cd). Otherwise Stata won't know where to load the data from cd "C:\Users\montonj2\OneDrive - Aalto University\PhD\Second Year\TA\Development Economics 1\HW2\Data_Extract_From_World_Development_Indicators" webuse invest2 *Now, if you want to calculate correlations for the whole sample, you simply write correlate and list the variables you are interested in. E.g.: correlate invest market *You can also add more variables correlate invest market stock *If you wish to calculate the correlation for a specific company, there are two ways of doing it *Either use the if option, or drop all other observations. When using "if", remember to always use double == signs correlate invest market if company == 1 *If the company name would be in text form (also called a string variable), you would need to use quotation marks when specifying the if condition. I will create an example of that now: gen company_str = "." replace company_str = "A" if company==1 replace company_str = "B" if company==2 replace company_str = "C" if company==3 replace company_str = "D" if company==4 replace company_str = "E" if company==5 *Then, the correlation calculation code would look like this: correlate invest market if company_str == "A" *If you decide to drop the rest of the observations (which only makes sense in cases when you are sure you won't need them at any point forward), you can write: keep if company == 1 *Or alternatively keep if company_str == "A" *The correlation calculation then becomes correlate invest market