BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
scooterpies
Calcite | Level 5

The goal is to create a new column called typical. The new variable is to hold the max value among columns stages 0 through 4. I am also looking to create a variable called theMax that outputs the column title that includes the max value found across the five stage count variables. 

 

Data typical2000_1;
Set typical2000;
theMax = max(stage_0, stage_i, stage_ii, stage_iii, stage_iv);
Run;

 

data typical2 (keep = primsite stage_0 stage_i stage_ii stage_iii stage_iv themax);
set typical2000_1;
proc print;
run;

 

data typical3;
set typical2;
rename stage_0 = stage0;
rename stage_i = stage1;
rename stage_ii = stage2;
rename stage_iii = stage3;
rename stage_iv = stage4;
run;

 

data want;
set typical3;
array s stage0 stage1 stage2 stage3 stage4;
maxvalue=max(of s(*));
maxvar=vname(s(whichn(maxvalue, of s(*))));
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You don't need VNAME, you can use WHICHN since your array is indexed from 0 to 4 in logical order. Then you can use the index-1 to indicate the stage.
You could also index the array using 0:4 instead of 1:5,

array s(0:4) stage0-stage4;

View solution in original post

1 REPLY 1
Reeza
Super User
You don't need VNAME, you can use WHICHN since your array is indexed from 0 to 4 in logical order. Then you can use the index-1 to indicate the stage.
You could also index the array using 0:4 instead of 1:5,

array s(0:4) stage0-stage4;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 492 views
  • 0 likes
  • 2 in conversation