BookmarkSubscribeRSS Feed
zjhansen30
Fluorite | Level 6

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;

3 REPLIES 3
Reeza
Super User

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.

 

 

 

zjhansen30
Fluorite | Level 6

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.

Reeza
Super User

Post your full code and log.

It should work, if it's not then something else is the issue.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2776 views
  • 0 likes
  • 2 in conversation