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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.