BookmarkSubscribeRSS Feed
PCrider
Calcite | Level 5
I have data concerning semester grades and GPAs. one variable is credits (contains the number of credits a class is worth) and another variable grade (contains the letter grade that was received in the class). I want to create a new variable using arrays that would be GPA (number of credits for a specific class*grade received in that class(i.e. 4.0 for an A, 3.7 for an A-, 3.4 for a B+, etc...). Does that make sense? Here is some sample data:

Class Credits LetterGrade

STAT 361 3.0 C
STAT 536 3.0 B+
ENGL 251 3.0 B
HLTH 129 1.0 D+
PE D 190 0.5 B+
PE D 270 1.0 B
PE D 478R 1.0 A-
PE S 129 0.5 A
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
Where do you envision using an ARRAY??? Are you thiinking of using an array construct for the lookup of the letter grade to the GPA??? In your case, I'd use a format for doing the lookup.

The format technique is shown on page 6 of this paper:
http://www2.sas.com/proceedings/forum2008/095-2008.pdf (and there are comparisons of other techniques as well)

This previous forum posting showed the use of a format to create a new variable:
http://support.sas.com/forums/thread.jspa?messageID=17511䑧 (at the bottom of the post)

cynthia
GeorgeLee
Calcite | Level 5
PCrider,

I don't think you'll need array for this. I agree with Cynthia on proc format. Below is a quick code I wrote, hope it helps. Don't forget to edit/complete the conversion list in proc format.

Best,

George
-----------------------------
proc format;
value $grade 'A' = 4 'A-' = 3.7 'B+' = 3.4 'B' = 3 'C+' = 2.3 'C' =2 'D+' = 1.3;
run;

data GPA;
infile 'H:\Personal\GPA.txt' dlm=',';
input coursenum $:9. credit :2. grade $:2.;
point_grade = put (grade, $grade.);
gpa = point_grade * credit;
run;

proc print data = gpa;
run;

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!

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.

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
  • 2 replies
  • 772 views
  • 0 likes
  • 3 in conversation