Student ID | NepaliScore | WordsperMinute | HowmuchtimeRemaining |
1 | 0 | 8 | 0 |
2 | 1 | 10 | 0 |
3 | 2 | 64 | 10 |
4 | 3 | 78 | 1 |
In my data, Student ID and NepaliScore are numeric variables but WordsperMinute and HowmuchtimeRemaining are string variables.
What I would like to do is
- Create new variable WPM whose value is 0 if NepaliScore is 0 and 1. But, WPM will be WordsperMinute if NepaliScore is 2 or 3
- Create new variable WPMCount which is equal to WPM if HowmuchtimeRemaining is equal to 0. But, if HowmuchtimeRemaining is not zero then WPMCount= WPM/60*(60+HowmuchtimeRemaining)
I tried using this solve it but the code is not generating output which it should:
encode(WordsperMinute),gen(WordsperminuteWPM)
gen WPM=.
replace WPM= 0 if NepaliScore<=1
replace WPM= WordsperminuteWPM if NepaliScore>1
encode(HowmuchtimeRemaining),gen(SecRem)
replace WPMCount= WPM if SecRem==.
replace WPMCount= WPM/60*(60+SecRem) if SecRem!=.
Thank you so much for help.
0 Response to Replacing string variables for Words per Minute Count with numeric variable and calculating new WPM for only those students ........
Post a Comment