Creating New Variables Using Stata

preview_player
Показать описание
This video introduces the programming concepts and syntax for creating new variables. The Stata commands covered include generate, replace, recode, label define, label values, label variable, and label data.
Рекомендации по теме
Комментарии
Автор

thank you, you have been a big help for me in doing my maters thesis.

auddjurhuus
Автор

Ricardo, there is no reply link on your posting, but a quick Internet search shows three different ways to gain access to the General Social Survey (GSS) data. Each link goes to a page that works a little differently, but you should be able to get to the data. The GSS a great social science dataset that is interesting to explore.


Best wishes,
Alan

smilex
Автор

Hi Alan. By chance I found this video. Perhaps if you don't mind you could help me with my issue. I'am working with a GMM model (dynamic panel data) and I need to collapse my data into 5-years averages and sd. I have created a new variable named period with each pair of year (eg. period=80 if year>=1980 & year<1985) and so on.. But when the time comes, and I collapse everything by (country period) the outcome is wrong. I guess I need to regard  each observation, don't I? 

Best Regards 

Santiago

santiagoc
Автор

Santiago,

The reply option is not showing up on your commune on Youtube.  Hopefully, you will see this reply.

It is hard to give you good advice without more information.  But, The Stata code below may be helpful.  It uses one of the example datasets that comes with Stata and show one way to collapse a dataset by year producing means and standard deviations.

Best,
Alan

smilex
Автор

Hi Alan. Maybe you can help me. I have a dataset which consists of two questionnaires. I want to create a age variable of the two variables with info on the age. So a new variable that combines two variables. How do I do that?
/Stine

Stine
Автор

hi! how can i recode a string variable to numeric variable. I want to recode principal occupation occupation into 4 levels .the principal occupation is a string variable .

goswaminilanjana
Автор

Alan, thanks for your videos. I have a quick question. Is it possible to randomly assign values in variable "x" to variable "y" (which only has missing values)?

Aurelaso
Автор

Hi sir
I need your help on how to generate instrumental variables according to ivreg2h using STATA. in other words, how to generate instrumental variables from my data because I don't have external instruments. The method developed by (Lewbel, 2012). Please you help is highly appreciated.

earningsmanagementestimati
Автор

Hi Alan! Thanks a lot for your videos

I just have a small question as I am having a small issue:

I am looking at trade flows between countries and I have the following 5 variables in my dataset:
COUNTRY PARTNER TRADE_FLOWS TIME GDP_COUNTRY

Now my problem is that I would like to generate a new variable that indicates the gdp of the PARTNER country as well, thus I will have :
COUNTRY PARTNER TRADE_FLOWS TIME GDP_COUNTRY GDP_PARTNER

All countries are included in COUNTRY and PARTNER, thus i am looking for a command that says: "if PARTNER= usa then GDP_PARTNER=GDP_COUNTRY when COUNTRY==usa

Any help with this will be greatly appreciated!!

Many Thanks!!

Best,

John

johndupont
Автор

Hi,
I need some help.
I have a variable which is monthly income but the data is from three different countries.
What command can i use to convert these incomes to US dollars since the denominator for each country currency is different.
Awaiting your response.
Thanks

ibidunnioloniniyi
Автор

Hi Alan. Would you mind helping me this situation? I import my data in excel into Stata. I want to use this data for tssmooth ma. But i cannot do it because Stata requires tsset varname. Then i creat a new var but when i use tssmooth ma, error is integer number accepted only (my data is decimal). Please help me! How can i use tssmooth ma in this situation?

loanpham
Автор

Sorry, i'm working on a dataset were they are missing values(represented with the "dots" (not really looking like the dot i saw in the preview data on which i've been working)), the problem here is that when i try to delete the missing values, stata (14) did not allow me to do it.

. drop if missing (hc)
missing not found
r(111);

end of do-file

r(111);
Please could You give me a hand. thks

foss
Автор

If the main goal is teach about create news variables, I just dont understand why the data isnt avaliable... =/

TheKaduzin
Автор

I have a few questions for my Master thesis about creating lag variables in stata. Is there a possibility you could help me with that?

KS

kevinsegers
Автор

Please help me with this. There are three questions about to clarify informal or formal sector.
1st one is EPF. Under this there are 3 answers
1-Yes
2-No
3-Don't know

2nd question
Whether your instituition keeping the accounts.
The same three answers

3rd one how many regular employees in your instituition
More than 10 consider as formal and less than 10 consider as informal.

In my data analysis I need to get all the formal as EPF yes, accounts yes and more than 10 employees and how to calculate the total employees in the formal sector that people who have EPF, accounts and more than 10 employees. Please help me with this.

afraakbar
Автор

Please help needed. I want to create "1" as ever married and "2" as never married. But there are 1 as married 2 never married 3 widowed 4 seperated 5 divorced. What is the code I have to use for this. Please help me

afraakbar