BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Markanti
Calcite | Level 5
I am attaching the question help me with this plZ its sas on demand. I got many errors
3. Use the instructions below and the code in the unfinished code section to finish creating dataset “three” in the HW library. (12 pts)
a. Add a variable called “agegroup” where
i. Agegroup = 1 for ages under 20
ii. Agegroup = 2 for ages 20 – under 30
iii. Agegroup = 3 for ages 30 – under 40
iv. Agegroup = 4 for ages 40 plus
b. Then add formatting for the agegroup variable as follows:
i. Under 20
ii. 20 – 30
iii. 30 – 40
iv. 40 & Over
c. Create a frequency table of race by agegroup for everyone not in group W2.
d. Display a list to the output window (show printout) of the following variables for only race = black: height, weight, & race, sorted in height order.
e. Find the mean weight for each gender group. Fill in the chart below:

Gender
Mean Weight
Females

Males

Unfinished Code

*HW 2 - Problem 3;
title " Using the where statement in procedures";
data hw.three;
​input ID Height Weight Pulse Systolic Diastolic Group Gender Race Age;
datalines;
11 61 179 82 128 80 W2 F Black 39.6
12 66 160 80 150 96 W3 F Black 11.4
13 71 198 72 150 99 W1 M White 40.6
14 61 172 99 120 80 W2 F Black 39.6
15 71 237 90 126 90 W1 F Black 24.2
16 67 204 78 106 64 W3 M Black 40.7
17 69 135 100 130 90 W4 M Black 29.1
18 71 237 103 162 108 W3 M Black 16.9
19 60 208 70 130 90 W4 F Black 31.7
20 61 193 74 130 80 W1 F White 48.6
;
run;
Finished Code
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Markanti wrote:
title " Using the where statement in procedures";
data hw.three;
​input ID Height Weight Pulse Systolic Diastolic Group Gender Race Age;
datalines;
11 61 179 82 128 80 W2 F Black 39.6
12 66 160 80 150 96 W3 F Black 11.4
13 71 198 72 150 99 W1 M White 40.6
14 61 172 99 120 80 W2 F Black 39.6
15 71 237 90 126 90 W1 F Black 24.2
16 67 204 78 106 64 W3 M Black 40.7
17 69 135 100 130 90 W4 M Black 29.1
18 71 237 103 162 108 W3 M Black 16.9
19 60 208 70 130 90 W4 F Black 31.7
20 61 193 74 130 80 W1 F White 48.6
;
run;


That data step will throw many invalid data messages for Group, Gender and Race. Until you fix that you can't do anything useful involving any of those variables. And assumes you have assigned the HW library.

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

As this is obviously a homework assignment, please show us what you have tried. I think all of us will help you fix your code if you can't get it to work, but we will not do your homework for you from scratch. Please make a reasonable effort to create code that will work.

 

As an aside, your instructor (or professor) seems confused here; there is no need for both a new variable named agegroup AND a format. A format by itself will work without the new variable agegroup.

--
Paige Miller
ballardw
Super User

@Markanti wrote:
title " Using the where statement in procedures";
data hw.three;
​input ID Height Weight Pulse Systolic Diastolic Group Gender Race Age;
datalines;
11 61 179 82 128 80 W2 F Black 39.6
12 66 160 80 150 96 W3 F Black 11.4
13 71 198 72 150 99 W1 M White 40.6
14 61 172 99 120 80 W2 F Black 39.6
15 71 237 90 126 90 W1 F Black 24.2
16 67 204 78 106 64 W3 M Black 40.7
17 69 135 100 130 90 W4 M Black 29.1
18 71 237 103 162 108 W3 M Black 16.9
19 60 208 70 130 90 W4 F Black 31.7
20 61 193 74 130 80 W1 F White 48.6
;
run;


That data step will throw many invalid data messages for Group, Gender and Race. Until you fix that you can't do anything useful involving any of those variables. And assumes you have assigned the HW library.

Markanti
Calcite | Level 5
Thanq so much I got it

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 616 views
  • 0 likes
  • 3 in conversation