![]() Next, we provide some examples that use the SAS code above. Text String Format SAS Code to Convert String to Date 31DEC2020 DATE9. The table below shows how to convert text strings of different formats into a SAS date. For example, SAS could interpret as October 11, 2020, or November 10, 2020. Notice that, if you use an incorrect format, the INPUT function returns a missing value, or worse, returns a numeric value that doesn’t correspond to the date in the text string. For example, if your text string is, then you need the MMDDYY10. This argument specifies how SAS interprets the text string of the first argument. The second argument of the INPUT function (i.e., date_format) is critical when you convert text into a date. This number represents a date in the SAS language. The INPUT function reads a string that looks like a date, and given its format (e.g., mm-dd-yyyy or ddmmmyyyy), returns a number. You can convert a text string into a SAS date with the INPUT function. ![]() Hence, you first need to convert them into an actual date before you can work with them. As a consequence, you can’t carry out operations with dates that are stored as strings. Even though a text string might look like a date, SAS doesn’t treat them as such.
0 Comments
Leave a Reply. |