Using all lower case makes it harder to read programs and follow the logic. And lower case or CamelFont for variable names. The extra typing, cutting and pasting time is more than offset during the debugging or future editing phase.Īnother tip, I always use UPPER CASE for SAS COMMANDS, FUNCTIONS, and OPERATORS. Also when trying to read programs written by others, those invisible variables make it much harder to follow the program logic. A variable name with a comma could be considered different from a variable name space comma. And I do use several different editors or other programs to edit SAS code. Search commands vary from editor to editor. I also endeavor to always keep a leading and trailing space at each variable name and operator. If a problem var does not show up, you can't find it, and good luck with the issues. Why? When you are trying to debug programs being able to search on each variable name is critical to tracking down problems. I learned long ago to never use these short cuts for variable names. The call to PROC REG uses the six variables in a linear regression: The syntax x1-圆 will select the six variables x1, x2, x3, x4, x5, and 圆 regardless of their physical order in the data. Notice that the data set variables are not in alphanumeric order. The following DATA step creates 10 variables, including the variables x1-圆. The first example can be specified as Sales2008-Sales2017. The hyphen enables you to specify the first and last variable in a list. In simulation studies, variables often have names such as X1, X2. For example, financial data might have variables that are named Sales2008, Sales2009. In many situations, variables are named with a common prefix and numerical suffix. Use a hyphen to specify numerical suffixes Sex Smoking_Status ) /* two character variables */ run Īn example of using the _ALL_ keyword is shown in the section that discusses the OF operator. Set Sashelp.Heart ( keep= _NUMERIC_ /* all numeric variables */ When you want to analyze all variables of a certain type, you can use these keywords, as follows: Many SAS procedures use a VAR statement to specify the variables to be analyzed. You can specify all character variables by using the _CHARACTER_ keyword. You can specify all numeric variables in a data set by using the _NUMERIC_ keyword. Use the _NUMERIC_, _CHARACTER_, and _ALL_ keywords However, for developing code and constructing examples, lists can be a huge time saver. If the number and names of variables in your data sets occasionally change, it is safer to manually list the variables that you are analyzing. Some companies might discourage the use of variable lists in production code because automated lists can be volatile. Use macro variables to specify variables that satisfy certain characteristics.Use the OF operator to specify variables in an array or in a function call.You can also use a variation of this syntax to specify a consecutive set of variables of a certain type (numeric or character).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |