2 weeks ago
I have a dataset that looks like following:-
ID Test_1 Test_2 Test_3 Test_4 Test_5 SH101 90.5 88.4 92.3 95.1 90.0 SH102 64.3 64.6 77.4 72.3 71.1 SH103 68.1 69.4 80.6 75.4 70.5
I want to increment values that are less than 65 to just above 65(say 65.01).
Please help me get this, I have no clue by what method we can increment this.
Thanks in advance!
2 weeks ago - last edited 2 weeks ago
I suspect you are getting confused by an array. And arrays can be confusing.
You need to test each value to see if it is greater or less than your
cutoff (65.0). If it is less than 65 than you want to change the value to 65.01
If given a variable TEST_1 and you want to do this test you would simply do this :
if TEST_1 < 65 then TEST_1 = 65.01;
You could repeat this statement for test_1, test_2, etc. over the entire data.
Instead of variable names you can use the array references if you declared this in an array (and that is how it looks)
A loop works great for this:
data youchanged ;
set yourdata ;
array test_ test_1 test_2 test_3 test_4 test_5 ;
do i = 1 to 5 ;
if . < TEST_[i] < 65 then do ; /**I ignore missing values they remain as missing values**/
TEST_[i] = 65.01 ;
I think you can drop inner loop and just have :
if . < var[i] < 65 then var[i] = 65.01 ;
You could also do this kind of test before you load the data to the array
Do you have missing values? These will test as <65 so the missing value would become 65.01 as well. Consider what is wanted.
A quick reference on using Do loops with arrays.
2 weeks ago