How to assign first variable of the array to 0 here? Below code creates rate1-rate11 taking values from 0.1 through 1.1. But I want rate1 starts at 0 so that rate11 would take 1.
data check; set temp;
array rate rate01-rate11;
do i=1 to dim(rate);
rate(i)=i/10;
end;
drop i;
run;
data check; set temp; array rate rate01-rate11 (0); do i=2 to dim(rate); rate(i)=(i-1)/10; end; drop i; run;
Art, CEO, AnalystFinder.com
data check; set temp; array rate rate01-rate11 (0); do i=2 to dim(rate); rate(i)=(i-1)/10; end; drop i; run;
Art, CEO, AnalystFinder.com
Bummer, I'm doing calculations using resulting array. The solution provided doesn't work with subsequent arithmetic functions. Any alternatives?
data check; set temp;
array rate rate01-rate21 (0);
do i=2 to dim(rate);
rate(i)=1+(i-1)/5;
end;
drop i;
run;
I don't understand what you're saying. Do the variables fate01 thru rate21 already exist in the file temp?
Show an example but, this time, include an example of what file temp looks like.
Art, CEO, AnalystFinder.com
This is temp:
this is what I'm trying to achieve:
data test_s1;
set temp(where=(county=1));
denom=tot_pop+sum_inflow-sum_outflow;
array rate rate01-rate21 (0);
do i=2 to dim(rate);
rate(i)=((tot_case+(agerisk*((i-1)/5)*sum_inflow)-agerisk*sum_outflow)/denom)*us_age_dist;
end;
drop i;
run;
the problem is that rate01 turns out to be 0 in test_s1. however, rate01 is not supposed to be zero, right?
You said, in your first post, that you want rate01 to have a value of 0. What am I missing?
Do you really only want rate01 to rate20 with each variable taking on the stated computation?
Art, CEO, AnalystFinder.com
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.