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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1966 views
  • 0 likes
  • 2 in conversation