For my data, I keep getting the error message ERROR: You are trying to use the character format $SEX with the numeric variable sex in data set WORK.STUDY2. I have tried formatting it in different ways but keep getting the same message, any help is appreciated.....
Proc format;
*formats the sex and race variable variable as in step 5;
value _sex
1='female'
2='male';
value _race
1='Asian'
2='Black'
3='Caucasian'
4='Other';
run;
Proc freq data=study2;
tables dosedate doselot site_name pt prot_amend limit sex race;
format sex $_sex. race $_race.;
run;
Proc freq data=study2;
tables dosedate doselot site_name pt prot_amend limit sex race;
format sex _sex. race _race.;
run;
You have numeric formats so you do not need the $ in front of the format, that is for character formats. A format type (numeric/character) is based on the input type, in this case 1/2.
You have two proc freqs in your code, the second set of code should have worked fine. If it didn't, please post the log.
The first proc freq would not have worked because of the $ sign.
Sorry, I was trying to show that I have used the format command both ways in the proc freq, and neither of them worked. It gives me the same error message no matter if I use the $ symbol or not.
Post your full code and log.
It should work, if it's not then something else is the issue.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.