format z YYMMDDN8.;
In this example zz is converted to a character from a date format. In my actual data when I use the above routine it stays as a date. It will not change from a date to a character. Is there some other way to convert from date to character?
Is there some other way to convert from date to character?
Once a variable type is assigned to a variable name in a SAS data set then the type cannot change. If you want to reuse the variable name with a new type then you basically rename the old variable to something else (or drop from the data set) and the create a new variable of the desired name.
You will find lots of examples on the forum related to fixing proc import created inconsistent variable types that look something like this:
set old (rename=(thisvar=oldnumvar);
thisvar = put(oldnumvar,z15.);
The format changes, or sometimes an INPUT function is called with an old character variable to create numeric.
There might follow a call to Proc Datasets to delete the prior dataset "old" and rename "new" to "old" to reuse the same data set name.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.