রবিবার, ৩১ আগস্ট, ২০১৪

Learning C Programming Lesson 7 Converting Variables

There might be times that you get a file that has numerous (or all) of the variables definite as strings, which is, character variables.


 Converting Variables


The variables might comprise numeric values, nonetheless if they are distinct as type string, here are very insufficient things you could do to examine the data.  You could not get means, you could not do a regression, you could not do an ANOVA, etc… Occasionally the data set comprises numerical values that are deposited as strings. We would address this situation first. Then we would address the situation where the string variables really contain strings, and the objective is to assign every value the string receipts on to numeric value.


Nowadays that we distinguish the Converting Variables are string variables, we could use the list command to understand what the strings deposited in these variables look similar. Though the variable discipline is distinct as str2, you could see from the list that this contains only numeric values. Even so, since the variable is defined as str2, Stata could not perform any sort of numerical examination of the variable discipline. The similar is true for variable read.


One technique of converting numbers deposited as strings into numerical variables is to usage a string function named real that interprets numeric values stowed as strings into numeric values Stata could recognize by itself. The main line of syntax states in the dataset. The second produces a novel variable read_n that is equivalent to the value of number stowed in the string variable recite. The real(s) is the function that interprets the values detained as strings, wherever s is the variable comprising strings.


A second technique of achieving the similar result is command destring. Let us try utilizing the destring command and see how this works. The main line of syntax loads the dataset yet again, so that we are beginning with a dataset comprising only string variables once more. Second line of syntax functions the destring command.


As you could see from the describe command, the destring command transformed all of variables to numeric, excluding for race, gender and schtyp. Meanwhile these variables consumed characters in them, the destring command leftward such variables unaccompanied. If there were any numeric variables in dataset, they would continue unchanged.




Learning C Programming Lesson 7 Converting Variables

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন