BookmarkSubscribeRSS Feed
ambreen
Calcite | Level 5
 I am not able to assign the formats to all of them except gender please help me with code
 
 
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= Mstudent 2 = Nurse 3-5 = Resident 6-10 = Fellow;
VALUE JudgedPreviously 1= Yes 2= No;
 VALUE Age  20-29 = second 30-39 = third 40 - 49 = fourth 50 - 59 = fifth;
RUN;
 PROC PRINT DATA= cdc.hw7;
FORMAT GENDER GENDER.  Occupation OCCUPATI. JudgedPreviously JUD.  AGE AGEAGE.;
run;
10 REPLIES 10
Reeza
Super User
Post your log.
ambreen
Calcite | Level 5
 
ambreen
Calcite | Level 5
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 libname _all_ clear;
NOTE: Libref CDC has been deassigned.
74 libname cdc "C:/Users/noor/Desktop/cups";
NOTE: Libref CDC was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\noor\Desktop\cups
75 data fda;
76 set cdc.hw7;
77 run;
 
NOTE: There were 37 observations read from the data set CDC.HW7.
NOTE: The data set WORK.FDA has 37 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.28 seconds
cpu time 0.06 seconds
 
 
78
79
80 PROC FORMAT;
81 VALUE Gender 1= Female 2 = Male;
NOTE: Format GENDER is already on the library WORK.FORMATS.
NOTE: Format GENDER has been output.
82 VALUE Occupation 1= Mstudent 2 = Nurse 3-5 = Resident 6-10 = Fellow;
NOTE: Format OCCUPATION is already on the library WORK.FORMATS.
NOTE: Format OCCUPATION has been output.
83 VALUE JudgedPreviously 1= Yes 2= No;
NOTE: Format JUDGEDPREVIOUSLY is already on the library WORK.FORMATS.
NOTE: Format JUDGEDPREVIOUSLY has been output.
84 VALUE Age 20-29 = second 30-39 = third 40 - 49 = fourth 50 - 59 = fifth;
NOTE: Format AGE is already on the library WORK.FORMATS.
NOTE: Format AGE has been output.
85 RUN;
 
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.15 seconds
cpu time 0.00 seconds
 
 
86 PROC PRINT DATA= cdc.hw7;
87 FORMAT GENDER GENDER. Occupation OCCUPATI. JudgedPreviously JUD. AGE AGEAGE.;
88 run;
 
NOTE: There were 37 observations read from the data set CDC.HW7.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.49 seconds
cpu time 0.14 seconds
 
 
89
90
91 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
104
PaigeMiller
Diamond | Level 26

No errors here, so please explain what the problem is in a lot more detail.

--
Paige Miller
ambreen
Calcite | Level 5
see my result in the file attached as mistake
I am not able to assign the values to observations except in gender


u can see if you see my result in file attached above
PaigeMiller
Diamond | Level 26

@ambreen wrote:
see my result in the file attached as mistake
I am not able to assign the values to observations except in gender


u can see if you see my result in file attached above

Many of us don't (or can't) download attachments. Why don't you post the output here in your reply, or better yet, explain the problem to us.

--
Paige Miller
ambreen
Calcite | Level 5
mistake_rtf
Reeza
Super User
Can't open attachments - work restrictions, please post directly into the forum.
Reeza
Super User
I don't see anything wrong in code or log, so that means it's a logic error. Can you retry this approach using SASHELP.CLASS data set and see what happens? If it works there, it's your data that's the issue somehow.
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

well @ambreen there are to many things wrong to point at just one.

Try this and see if you can find out what you did wrong.

 

data fda;

*set cdc.hw7;
input gender occupation judgedpreviously age;
cards;
1	1	1	21
1	1	1	48
2	2	1	54
2	1	2	35
;


PROC FORMAT;
VALUE Gender  1= 'Female'  2 = 'Male';
VALUE Occupation 1= 'Mstudent' 2 = 'Nurse' 3-5 = 'Resident' 6-10 = 'Fellow';
VALUE JudgedPreviously 1= 'Yes' 2= 'No';
 VALUE Age  20-29 = 'second' 30-39 = 'third' 40 - 49 = 'fourth' 50 - 59 = 'fifth';
RUN;
 PROC PRINT DATA= fda ;/*cdc.hw7;*/
FORMAT GENDER GENDER.  Occupation Occupation. JudgedPreviously JudgedPreviously.  AGE AGE.;
run;
The SAS System 


Obs gender occupation judgedpreviously age 
1 Female Mstudent Yes second 
2 Female Mstudent Yes fourth 
3 Male Nurse Yes fifth 
4 Male Mstudent No third 


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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