BookmarkSubscribeRSS Feed
ambreen
Calcite | Level 5
libname _all_ clear;
libname cdc "C:/Users/noor/Desktop/cups";
data fda;
set cdc.hw7;
run;

PROC FORMAT;
VALUE Gender  1= 'Female'  2 = 'Male';
VALUE Occupation 1= 'Medical student' 2 = 'Nurse' 3-5 = 'Resident' 6-10 = 'Fellow';
VALUE JudgedPreviously 1='Yes' 2= 'No';
 VALUE Age  20 -29 = '2 '
 30-39 = '3'
    40 - 49 = '4'
    50 - 59 = '5';
 RUN;
 PROC PRINT DATA= cdc.hw7;
FORMAT GENDER FEMALE.  Occupation residents. JudgedPreviously yes.  AGE 2.;
run;
 
 
 
 
 
my final report is not giving the assign values 
please tell me whats wrong with my code
3 REPLIES 3
FreelanceReinh
Jade | Level 19

Hi @ambreen,

 

It's the FORMAT statement in the PROC PRINT step:

You are using the syntax

FORMAT format_name1 label1. format_name2 label2. ...

but the correct syntax (see documentation: FORMAT Statement) is

FORMAT variable_name1 format_name1. variable_name2 format_name2. ...

So, you need to look into dataset cdc.hw7 (or its copy, fda) to find out the names of the four variables to be formatted. You may want to create a list of all variables in the dataset by means of PROC CONTENTS:

proc contents data=fda;
run;

Depending on the variable names (which could be, say, sex, occup, jprev and age), your FORMAT statement might look like

format sex Gender. occup Occupation. jprev JudgedPreviously. age Age.;

 

There is a remote possibility that one or more of the four variables are in fact character variables (see column "Type" in the PROC CONTENTS output). This would cause an error message in the log when you submit the PROC PRINT step, e.g.:

ERROR: You are trying to use the numeric format GENDER with the character variable sex in data set CDC.HW7.

Only in this case you would need to modify the corresponding format definition in the PROC FORMAT step (and rerun that step), e.g.:

VALUE $Gender  '1'= 'Female'  '2' = 'Male';

and use $Gender. instead of Gender. in the FORMAT statement.

ambreen
Calcite | Level 5
 I have checked all of tgem are numeric variables 
FreelanceReinh
Jade | Level 19

Great. So, the suggested solution in the first part of my response should work for you. Have you tried it?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

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