## Help with maximum and array

Occasional Contributor
Posts: 9

# Help with maximum and array

Hello all,

I have a project for a class that asks me to do 3 things

• Use PROC TRANSPOSE to restructure the converted SAS data set as described in the Word document
• Using ARRAY statement to compute the Cmax and Tmax
• For each patient, compute the following: MEAN of the concentration values and MINIMUM of the concentration values.

I have completed all of the tasks correctly, except computing Tmax .

For this part of my project I have:

data temp3;

set project2_transposed;

array conc[13] C1-C13;

Cmax= max(of conc{*});

array times[13] T1-T13;

Tmax= max(of times(of Cmax);

by subject;

run;

proc print data= temp3;

title "Part3";

run;

I know Tmax is the maximum time from the point where the Concentration is highest. So I thought it would be Tmax = time of Cmax.

Again, Cmax is correct, and I do not get any errors in my log. However, the output numbers from Tmax are incorrect. If anyone could offer any advice I would be grateful.

Thank you,

Mackenzie

Posts: 5,482

## Re: Help with maximum and array

[ Edited ]

Hint: look at function WHICHN()

mackenzies3 wrote:

Hello all,

I have a project for a class that asks me to do 3 things

• Use PROC TRANSPOSE to restructure the converted SAS data set as described in the Word document
• Using ARRAY statement to compute the Cmax and Tmax
• For each patient, compute the following: MEAN of the concentration values and MINIMUM of the concentration values.

I have completed all of the tasks correctly, except computing Tmax .

For this part of my project I have:

data temp3;

set project2_transposed;

array conc[13] C1-C13;

Cmax= max(of conc{*});

array times[13] T1-T13;

Tmax= max(of times(of Cmax);

by subject;

run;

proc print data= temp3;

title "Part3";

run;

I know Tmax is the maximum time from the point where the Concentration is highest. So I thought it would be Tmax = time of Cmax.

Again, Cmax is correct, and I do not get any errors in my log. However, the output numbers from Tmax are incorrect. If anyone could offer any advice I would be grateful.

Thank you,

Mackenzie

PG
Occasional Contributor
Posts: 9

## Re: Help with maximum and array

Thank you for your hint, but could you please expand a little bit?

I'm very new to sas and we have yet to learn WHICHN() in my class.
Posts: 5,482

## Re: Help with maximum and array

Learn about it in SAS documentation. All users, experienced or not, look at it every day.

PG
Occasional Contributor
Posts: 9

## Re: Help with maximum and array

I guess I just am having trouble understanding how exactly to go from having the max of the concentration (Cmax), and max of time, to finding the time of the highest concentration (Tmax).

We have 13 times, and 13 concentrations for 7 different subjects.
and the highest time is 32 for all of the subjects, but the highest concentrations differ between each subject.

For instance, subject 1 has the highest concentration of 4.7 at time 2.
but then subject 2 has the highest concentration of 4.7 at time 3.

So I'm very confused on how to make the Tmax = 2 for subject 1, but Tmax = 3 for subject 3 and so on.

And I did look at WHICHN() but I don't even know where I would start with that. But thank you for your hint. I will be looking/trying.
Posts: 5,482

## Re: Help with maximum and array

Good thinking so far. Since the conc and times arrays correspond elementwise, what you are looking for is the position of cmax in array conc in order to return the corresponding element from array times. Finding the position of cmax in array conc is what WHICHN can do...

PG
PROC Star
Posts: 2,318

## Re: Help with maximum and array

@PGStats It looks like this forum is more and more about home work. Maybe we're nearing end-of-term / end-of year.

Posts: 5,482

## Re: Help with maximum and array

I hope the teachers are wise enough to check the forum.

PG
Occasional Contributor
Posts: 9

## Re: Help with maximum and array

It's an online graduate course so we don't have access to traditional teaching settings or in-person help. It's harder to learn solely based on online lectures. The internet is an important tool to help us truly understand.

Posts: 5,482