Using arrays in SAS -


i've got data file has 5 test scores 20 students. each test score has own passing grade of 68, 70, 72, 74, 76 respectively.

i read in data .dat file need calculate number of tests passed each student. easy using if statements, need utilize arrays here. code looks like

data test_scores; infile '---------------------------------'; input t1 t2 t3 t4 t5; array test_scores{5} t1 t2 t3 t4 t5; n=1 5;     if tests[i] = 

this stuck. realize can if index 1 , test score greater 68, add accumulator variable tests_passed , 5 seems redundant , started with. appreciated!

since score cutoffs evenly spaced, do:

do n=1 5;     if test_scores[n] >= 66 + 2 * n 

but that's not extensible, perhaps better method have array of cutoff scores:

array pass_cutoff{5} 68 70 72 74 76; n=1 5;     if test_scores[n] >= pass_cutoff[n] 

this way, if cutoff changes, update array initialization, , still works.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -