Hi is there anyone who has helpful information regarding the function 'numlist'
I have check statahelp, stata journal and youtube and some previous posts posted on this forum
I still have these questions:
I understand that numlist refers to a range of numbers
However, what I don't understand is how does stata know which range of numbers you are referring to?
Say I have 4 columns in the midst of 25 columns of data with over 1 million rows, how does stata know which 4 columns I'm referring to if I need to use create a loop to cycle through the 4 columns to detect a particular code eg T76, T77, T89
Basically I'm trying to do the following -
Please note I posted the same dataset on here: https://www.statalist.org/forums/for...tring-function using a substring function, but I've decided to change course of attack.
Instead I'll be picking out the pathologies I need and creating new columns rather than going through all the fields within my database.
Example generated by -dataex-. For more info, type help dataex clear input float(Diagnosis1 Diagnosis2) str1 Diagnosis3 str4(Diagnosis4 Diagnosis5) 3 3 "3" "T345" "T345" 3 3 "4" "T88" "T77" 34 4 "4" "T76" "T88" 3 3 "4" "T76" "A76" 3 4 "3" "A89" "A89" 3 3 "4" "A09" "A09" 4 5 "6" "T89" "T89" end Lets say stroke = T76, T77, T89 I need to create a column with stroke = 1 Therefore gen stroke = 0 foreach num of numlist 3 4 { replace stroke = 1 if dg_'num >= T76 & dg_'num' <=T89
Thanks
I have check statahelp, stata journal and youtube and some previous posts posted on this forum
I still have these questions:
I understand that numlist refers to a range of numbers
However, what I don't understand is how does stata know which range of numbers you are referring to?
Say I have 4 columns in the midst of 25 columns of data with over 1 million rows, how does stata know which 4 columns I'm referring to if I need to use create a loop to cycle through the 4 columns to detect a particular code eg T76, T77, T89
Basically I'm trying to do the following -
Please note I posted the same dataset on here: https://www.statalist.org/forums/for...tring-function using a substring function, but I've decided to change course of attack.
Instead I'll be picking out the pathologies I need and creating new columns rather than going through all the fields within my database.
Example generated by -dataex-. For more info, type help dataex clear input float(Diagnosis1 Diagnosis2) str1 Diagnosis3 str4(Diagnosis4 Diagnosis5) 3 3 "3" "T345" "T345" 3 3 "4" "T88" "T77" 34 4 "4" "T76" "T88" 3 3 "4" "T76" "A76" 3 4 "3" "A89" "A89" 3 3 "4" "A09" "A09" 4 5 "6" "T89" "T89" end Lets say stroke = T76, T77, T89 I need to create a column with stroke = 1 Therefore gen stroke = 0 foreach num of numlist 3 4 { replace stroke = 1 if dg_'num >= T76 & dg_'num' <=T89
Thanks
Comment