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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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