Example: bachelor of science

Extensions to generate - Stata

Extensions to generateDescriptionQuick startMenuSyntaxRemarks and examplesAcknowledgmentsReferencesAlso seeDescriptionegencreates a new variable of the optionally specified storage type equal to the given functionbased on arguments of that function. The functions are specifically written foregen, as documentedbelow or as written by startGeneratenewv1for distinct groups ofv1andv2, and create and apply value labelmylabelegen newv1 = group(v1 v2), label(mylabel)Generatenewv2equal to the minimum ofv1,v2, andv3for each observationegen newv2 = rowmin(v1 v2 v3)Generatenewv3equal to the overall sum ofv1egen newv3 = total(v1)As above, but calculate total within each level ofcatvaregen newv3 = total(v1), by(catvar)Generatenewv4equal to the number of nonmissing numeric values acrossv1,v2, andv3for eachobservationegen newv4 = rownonmiss(v1 v2 v3)As above, but allow string valuesegen newv4 = rownonmiss(v1 v2 v3)

Generate newv4 equal to the number of nonmissing numeric values across v1, v2, and v3 for each observation egen newv4 = rownonmiss(v1 v2 v3) As above, but allow string values egen newv4 = rownonmiss(v1 v2 v3), strok Generate newv5 as the concatenation of numeric v1 and string v4 separated by a space egen newv5 = concat(v1 v4), punct(" ") Menu

Tags:

  Value, Separated

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Extensions to generate - Stata

1 Extensions to generateDescriptionQuick startMenuSyntaxRemarks and examplesAcknowledgmentsReferencesAlso seeDescriptionegencreates a new variable of the optionally specified storage type equal to the given functionbased on arguments of that function. The functions are specifically written foregen, as documentedbelow or as written by startGeneratenewv1for distinct groups ofv1andv2, and create and apply value labelmylabelegen newv1 = group(v1 v2), label(mylabel)Generatenewv2equal to the minimum ofv1,v2, andv3for each observationegen newv2 = rowmin(v1 v2 v3)Generatenewv3equal to the overall sum ofv1egen newv3 = total(v1)As above, but calculate total within each level ofcatvaregen newv3 = total(v1), by(catvar)Generatenewv4equal to the number of nonmissing numeric values acrossv1,v2, andv3for eachobservationegen newv4 = rownonmiss(v1 v2 v3)As above, but allow string valuesegen newv4 = rownonmiss(v1 v2 v3)

2 , strokGeneratenewv5as the concatenation of numericv1and stringv4separated by a spaceegen newv5 = concat(v1 v4), punct(" ")MenuData>Create or change data>Create new variable (extended)12 egen Extensions to generateSyntaxegen[type]newvar=fcn(argum ents)[if][in][,options]byis allowed with some of theegenfunctions, as noted onfcn,argumentsrefers to an expression,varlist, ornumlist, and theoptionsare its dependencies are listed (varlist), values(integer numlist)may not be combined withby. It returns the number of variables invarlistfor which values areequal to any integer value in a suppliednumlist. Values for any observations excluded by eitheriforinare set to 0 (not missing).

3 Also seeanyvalue(varname)andanymatch(varlist) .anymatch(varlist), values(integer numlist)may not be combined withby. It is 1 if any variable invarlistis equal to any integer value ina suppliednumlistand 0 otherwise. Values for any observations excluded by eitheriforinare set to 0 (not missing). Also seeanyvalue(varname)andanycount(varlist) .anyvalue(varname) , values(integer numlist)may not be combined withby. It takes the value ofvarnameifvarnameis equal to anyinteger value in a suppliednumlistand is missing otherwise. Also seeanymatch(varlist)andanycount(varlist) .concat(varlist)[, format(%fmt) decode maxlength(#) punct(pchars)]may not be combined withby. It concatenatesvarlistto produce a string variable.

4 Values ofstring variables are unchanged. Values of numeric variables are converted to string, as is, orare converted using a numeric format under theformat(%fmt)option or decoded under thedecodeoption, in which casemaxlength()may also be used to control the maximum labellength used. By default, variables are added end to end:punct(pchars)may be used to specifypunctuation, such as a space,punct(" "), or a comma,punct(,).count(exp)(allowsbyvarlis t:)creates a constant (withinvarlist) containing the number of nonmissing observations seerownonmiss()androwmiss().cut(varname) ,{at(numlist)|group(#)}[icodes label]may not be combined withby. Eitherat()orgroup()must be specified.

5 Whenat()isspecified, it creates a new categorical variable coded with the left-hand ends of the groupingintervals specified in theat()option. Whengroup()is specified, groups of roughly equalfrequencies are (numlist)withnumlistin ascending order supplies the breaks for the setto missing for observations withvarnameless than the first number specified inat()and forobservations withvarnamegreater than or equal to the last number specified inat().group(#)specifies the number of equal-frequency grouping intervals when breaks are notspecified. Specifying this option automatically that the codes 0, 1, 2, etc., be used in place of the left-hand ends of that the integer-coded values of the grouped variable be labeled with the left-handends of the grouping intervals.

6 Specifying this option automatically (varlist)may not be combined withby. It creates an indicator variable equal to 1 if the variables invarlistare not equal and 0 Extensions to generate 3ends(strvar)[, punct(pchars) trim[head|last|tail]]may not be combined withby. It gives the first word or head (with theheadoption), thelast word (with thelastoption), or the remainder or tail (with thetailoption) from ,last, andtailare determined by the occurrence ofpchars, which is by default onespace ( ).The head is whatever precedes the first occurrence ofpchars, or the whole of the string if itdoes not occur. For example, the head of frog toad is frog and that of frog is frog.

7 Withpunct(,), the head of frog,toad is frog .The last word is whatever follows the last occurrence ofpcharsor is the whole of the stringif a space does not occur. The last word of frog toad newt is newt and that of frog is frog . Withpunct(,), the last word of frog,toad is toad .The remainder or tail is whatever follows the first occurrence ofpchars, which will be theempty string""ifpcharsdoes not occur. The tail of frog toad newt is toad newt and thatof frog is"". Withpunct(,), the tail of frog,toad is toad .Thetrimoption trims any leading or trailing (numlist)may not be combined withby. It creates a variable of ascending or descending numbers orcomplex repeating contain at least two numbers and may be specifiedusing standardnumlistnotation; see[U] not allowed withfill().

8 Group(varlist)[, missing autotype label[(lblname[, replace truncate(#)])]]may not be combined withby. It creates one variable taking on values 1, 2,..for the groupsformed contain numeric variables, string variables, or a combination ofthe two. The order of the groups is that of the sort order that missing values invarlist( "") are to be treated like any othervalue when assigning groups. By default, any observation with a missing value is assigned tothe group withnewvarequal to missing (.).autotypespecifies thatnewvarbe the smallesttypepossible to hold the integers resultingtypewill bebyte,int,long, (lblname)creates a value label fornewvar. The integers innewvarare labeledwith the values ofvarlistor their value labels, if they (lblname)specifieslblnameas the name of the value label.

9 Iflabelalone is specified, the name of the value label (.., replace)allows an existing value label to be (..,truncate(#))truncates the values contributed to the label from each variable invarlistto thelength specified by the integer argument#.iqr(exp)[, autotype](allowsbyvarlist:)creates a constant (withinvarlist) containing the interquartile range the smallesttypepossible to hold the result. The resultingtypewill bebyte,int,long, ordouble. Also seepctile().kurt(exp)(allowsbyvarlist:)r eturns the kurtosis (withinvarlist) (exp)(allowsbyvarlist:)returns the median absolute deviation from the median (withinvarlist) egen Extensions to generatemax(exp)[, missing](allowsbyvarlist:)creates a constant (withinvarlist) containing the maximum value missing values be treated like other (exp)(allowsbyvarlist:)returns the mean absolute deviation from the mean (withinvarlist) (exp)(allowsbyvarlist:)creates a constant (withinvarlist) containing the mean (exp)[, autotype](allowsbyvarlist:)creates a constant (withinvarlist) containing the median thatnewvarbe the smallesttypepossible to hold the result.

10 The resultingtypewill bebyte,int,long, ordouble. Also seepctile().min(exp)[, missing](allowsbyvarlist:)creates a constant (withinvarlist) containing the minimum value missing values be treated like other (varname)[, minmode maxmode nummode(integer) missing](allowsbyvarlist:)produces the mode (withinvarlist) forvarname, which may be numeric or string. The modeis the value occurring most frequently. If two or more modes exist or ifvarnamecontainsall missing values, the mode produced will be a missing value . To avoid this, theminmode,maxmode, ornummode()option may be used to specify choices for selecting among the the lowest value , andmaxmodereturns the highest (#)returns the#th mode, counting from the lowest that missing values betreated like other (exp)[, prop](allowsbyvarlist:)returnsexp(within varlist) scaled to be a percentage of the total, between 0 and 100.


Related search queries