This example shows how you can get a list of variables that are inside one local, but not inside another one. Capture mkdir tempDisplay "Here goes the code you would use when var2 does exist"Display "Here goes the code you would use when var2 does NOT exist"3. But in case the folder was already created (during earlier code run) then you would simply add the capture command to override the erorr.The second example is slightly more complex, and it shows how to use the capture command to:A) combine content of variables var1 and var2 when they both exist,B) rename var1 to var2 when var2 doesn’t exist.The example also shows how _rc is to be used, where _rc denotes the case where the command inside the capture returns an error and !_rc denotes the case where the command inside the capture does not return an error. The first example below creates a folder called temp. PRC Statistical Consultant. Haley Stritzel, PhD Candidate in Sociology.Use the second line below to extract the number of items in a list. If _N > 0Display "Here comes code that should be ran if data not empty"5. Use code below to make sure data is use is not empty. Local local1 "A B C"Display "`difference'" CONDITION THAT MAKES SURE DATA IN USE IS NOT EMPTY4.
![]() Stata Ro Code You WouldThe ds command is a super useful and super flexible command which, when used properly, can save you tons of time and code. Local varlabel: variable label varname7. You may want to do so, for example, when importing data from Excel didn’t result in proper variable names, so you want to pull them from the labels. Use the code below when you want to extract the label of a variable. Local varlist a b cLocal items_number : list sizeof local(varlist)Display "`items_number'" EXTRACT VARIABLE LABEL TO A LOCAL6. Generate a matrix with the number of rows/columns equal to the number of items in a list. Audio spectrum analyzer pc softwareThe last example also shows how you would use the variable list in a further step.
0 Comments
Leave a Reply. |
AuthorAmanda ArchivesCategories |