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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.