Hi everyone,
I am having issues changing my DATE column from a CHAR to a NUM so that I can do a join with another table.
The code runs, however when I check the properties, the "accurate_episode_date"'s property is still CHAR.
Here is the code:
data main2; set covid.covid;
format test_date mmddyy10.;
test_date = input(Accurate_Episode_Date,date9.);
run;
Thanks
1) you can't change the type of an existing variable
2) you created a new variable test_date that should be numeric and display in the Date9. format. That is the one to look at as your code did not even attempt to change Accurate_Episode_Date.
@JibJam221 wrote:
Sorry I meant to say that test_date didnt change to a NUM variable. Any suggestions on how to make test_date a NUM var?
You cannot change the type of an existing variable. So if TEST_DATE already appeared as a character variable in your source dataset then just trying to attach a numeric format to it or assign a numeric value to it would not change how it was already defined.
Check that TEST_DATE does not already exist on COVID.COVID. If it does then you can use DROP= or RENAME= dataset option to get it out of the way so you can use TEST_DATE as the name of your NEW variable.
data main2;
set covid.covid (drop=test_date);
format test_date mmddyy10.;
test_date = input(Accurate_Episode_Date,date9.);
run;
Please post the complete log of that step.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.