Convert numeric to character sas4/6/2023 * contain a list of each new numeric variable separated by a blank space. The next macro variable named N_list will */ * macro variable named C_list will contain a list of each character variable */ * PROC SQL is used to create three macro variables with the INTO clause. * The macro system option SYMBOLGEN is set to be able to see what the macro */ * variable names is created from the character variable name with a "_n" */ * variables and exclude the one ID character variable. * A DATA step is used to subset the VARS data set to keep only the character */ Proc contents data=test out=vars(keep=name type) noprint * variable names and their type from the TEST data set. * PROC CONTENTS is used to create an output data set called VARS to list all */ * The sample data set TEST contains both character and numeric variables */ In addition, SAS Institute will provide no support for the materials contained herein. Not be liable for any damages whatsoever arising out of their use of this material. Recipients acknowledge and agree that SAS Institute shall "as is" without warranty of any kind, either express or implied, includingīut not limited to the implied warranties of merchantability and fitness for a These sample files and code examples are provided by SAS Institute The SQL procedure is used to create the macro variables and the DATA step is used to convert the values from character to numeric.Ĭlick the Full Code tab to view the sample program and further details about the process. One contains the list of character variable names, the second contains the list of new numeric variable names, and the third contains the list of new numeric variables names set equal to the list of character variable names for the RENAME statement. In general, a list of all the character variables will be used to create three macro variables. This sample shows how to convert all character variables to numeric while excluding one character variable and keeping the same variable names in the output data set.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |