Hi,
I think you just need to use the DIM function.
Array demography [*] $ C_sex D_DOB D_AGE E_POPULATION;
number_of_elements=dim(demography);
I think you just need to use the DIM function.
Array demography [*] $ C_sex D_DOB D_AGE E_POPULATION;
number_of_elements=dim(demography);
i has nothing to do with the array. i is an incrementor. The process for the do loop: do i=1 to 4;
Is;
set i to 1
Is i > end of loop
No - run code inside
set i to i + 1
Is i > end of loop
No - run code inside
As you can see each time the loop enacts i is incremented, the loop does not run the code enclosed with the loop block when i > 4, however i still gets incremented by 1, as otherwise i would never be greater than the end of loop. What is it your actually trying to achieve (post full example) as:
data have; set sashelp.class; if _n_=4 then weight=.; if _n_=8 then sex=""; run; data want; set have; result=nmiss(age,weight,height) + cmiss(sex); run;
Is a simpler solution.
"number_of_elements=dim(demography); " worked. Thank you for the responses.
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.