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

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';
 PROC PRINT DATA= cdc.hw7;
FORMAT GENDER FEMALE.  Occupation residents. JudgedPreviously yes.  AGE 2.;
my final report is not giving the assign values 
please tell me whats wrong with my code
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;

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.

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

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



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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
  • 2 in conversation