BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MinalMurkhande
Calcite | Level 5

Hi ,

   On running the format procedure I get and Error saying : " You are trying to use the numeric format SURVIVED with the character variable Survived in data set TITANIC.TRAIN."

Here is my code :

proc format;

value survived 1='Survived'

               0='Died'

     ;

  run;

ods graphics on;

proc freq data=titanic.train;

tables survived sex Pclass

survived*sex survived*pclass/

plots(only)=freqplot(scale=percent);

format survived survived.;

run;

When I change the "Survived" column to numeric datatype it works. How do I apply the format procedure to a character datatype column.?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

format survived $survived.;

View solution in original post

4 REPLIES 4
Reeza
Super User

Make a character format:

proc format;

value $ survived '1'='Survived'

              '0'='Died'

     ;

  run;

MinalMurkhande
Calcite | Level 5

Hi Reeza,

Thank you for your reply.

I did try this option too but it still gives the same error .

Here is the excerpt from the log :

NOTE: Format $SURVIVED is already on the library WORK.FORMATS.

NOTE: Format $SURVIVED has been output.

29         run;

NOTE: PROCEDURE FORMAT used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

30         ods graphics on;

31         proc freq data=titanic.train;

32         tables survived sex Pclass

33         survived*sex survived*pclass/

34         plots(only)=freqplot(scale=percent);

35         format survived survived.;

ERROR: You are trying to use the numeric format SURVIVED with the character variable Survived in data set TITANIC.TRAIN.

36         run;

NOTE: The SAS System stopped processing this step because of errors.

Reeza
Super User

format survived $survived.;

MinalMurkhande
Calcite | Level 5

Thank you.. ! Got it Smiley Happy

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
  • 4 replies
  • 12175 views
  • 0 likes
  • 2 in conversation