I am trying to create a loop across variables in PROC SQL, but my code does not work. I know how to do it manually: proc freq data=sashelp.class nlevels; tables name age sex; title 'Number of distinct values for each variable'; run; /* Using PROC SQL to count the number of levels for a variable. */ proc sql; create table new1 as select count(distinct(name)) as namecount, count(distinct(age)) as agecount, count(distinct(sex)) as sexcount from sashelp.class; quit; But I am trying to come up with the way to use the loop across variables, such as: % let list = age height weight ; data sql.count_test; set sashelp.class; array var_list(*) &list; do i=1 to dim(var_list); variable=var_list(i); output; end; proc sql; create table new2 as select count(distint(variable)) as variable_count from sql.count_test; quit; Now, how the program should be modified if we also have a date component? Thank you for your help!
... View more