Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Creating a new variable sum the percentage of total group

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 10-01-2018 10:21 PM
(1628 views)

Hello guys! I just start teaching myself to use SAS and sinceI have very little experience with programming languages. I would be very appreciative of any help with this problem! like how to set the variable with percentage of total observations.

DATA school;

INPUT age quiz : $1. midterm final;

/* Add your code here */

DATALINES;

12 A 92 95

12 B 88 88

13 C 78 75

13 A 92 93

12 F 55 62

13 B 88 82

;

RUN;

The quiz grades have numerical equivalents as follows: A = 95, B = 85, C = 75, D = 70, and F = 65. Using this information, compute a new variable called **course** that represents the final grade for each student. The final grade is a weighted average of all grades where quiz grades are worth 30%, midterm grades are worth 30%, and final grades are worth 40%.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here's a nudge in the right direction.

Add as many statements as you need, not just one. (Some posters may show you how to do this in one statement, but that's not the right way to learn until you have more experience.)

Start by creating a new variable, holding the numeric equivalent of the letter grade. Then calculate the final grade using three numeric variables in your formula.

Show what you have tried, if you need a further nudge.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

A=95 B=85 C=75 D=70 F=65;

Finalgrades= 0.3*quiz+0.3*midterm+0.3*final;

Am i in the right track?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You are further along than before. But you need working code, and you need to be able to test that code. At this point, I see no evidence of any code that you could actually test.

Start by creating a new variable named QUIZ_NUMERIC that takes on numeric values instead of "A", "B", "C", "D" and "F". Whatever statements you use to do that, make them part of a DATA step that you can then run and see whether the results are coming out correctly.

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

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.

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