From Stata\'s command line generate the data set below a) From Stata\'s command
ID: 3662238 • Letter: F
Question
From Stata's command line generate the data set below
a) From Stata's command line generate a new variable named v4 with values 1
in row 1, 2 in row 2, and 1 in row 3.
b) Rename the variable v4 as sex and definene value labels for sex as
1=male, 2=female
c) Generate a new index variable named id that assigns a unique number
to each of the current observations (hint: use the generatecommand in
conjunction with the _n system variable).
d) Rename the variables v1, v2, and v3 as time1, time2, and time3
(e) Use the reshape command to convert the data set into long form by year.
(f) Generate a new variable named dthat is equal to the
squared diference between the variable time at each
occasion and the average of time for each subject(hint: you'll
need to use the egen command).
(g) Drop the observation corresponding to the third year for id=2
V1 V2 V3 1 3 5 2 16 3 5 12 2Explanation / Answer
a)
generate v4 = .
b)
rename v4 sex
label define myLabel 1 "Male" 2 "Female"
c)
d)
rename v1 time1
rename v2 time2
rename v3 time3
e)
reshape long year , i(id) j(sex)
g)
drop time3 if id=2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.