Informats are better suited to converting character to numeric or character to character. In general, it is best to use a format when converting from numeric to character. UPCASE, as the name implies, will convert the data values to uppercase before checking on the informat ranges. There are some useful options that you can use when you create your informats. If you used the name $marks instead of marks as in this program, the variable marks would be a character. The name of the informat is followed by the INVALUE keyword and a dollar sign are used to create character informat.Įven though you are reading character values, the resulting data will be a numeric variable. In creating an informat, the right-hand side of the equals sign in the INVALUE statement can be numeric. One important distinction is that the right-hand side of the equals sign in a VALUE statement (the ‘label’ side) for a format must be a character. You first create a multilabel format like this:Ĭreating informats is similar to creating formats except the VALUE statement is replaced with an INVALUE statement. You want to see the variable Age (from the SURVEY data set) broken down two ways-one, in 20 year intervals the other by a split at 50 years old. However, you can create a format with overlapping ranges if you use the multilabel option on the VALUE statement.Ĭertain multilabel enabled procedures can then use the multilabel format to produce tables showing all of the format ranges. Under normal circumstances, you get an error message if any of your formats ranges overlap. You can use nested formats as follows to accomplish this task: proc format Dates before July 15, 2005, should be formatted as "Not Open" and dates after December 31, 2006, should be formatted as "Too Late." You want to read dates from July 15, 2005, to December 31, 2006, using the mmddyy10. You can also include the name of a SAS format or user-defined format or informat, rather than a text string in place of a label. So, in this example, missing values and any values beginning with numbers will be labelled as 'Error '. In an alphabetical sort, SAS sorts numeric values before A. All other values (including missing) will be displayed as 'Error '. In the above example Any values which come after A (including A) and before K (not including K), in an alphabetical sort, will be labelled as ‘First 10’.Īny values which come after K (including K) and before U (not including U), in an alphabetical sort, will be labelled as 'Second 10'.Īny values which come after 'U' (including U) will be labelled as 'Remaining'. We could create the following proc format We can also apply the basic principles of ranges to character formats as well.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |