Hello everyone,
I am having issues with dropping a variable within the program I wrote. The code runs cluster analysis for different values of clusters. The prefix of the name of the generated grouping variables is given by the argument in the cluster_name. If the grouping variables already exists, I would like to drop them. I thought this was a straight forward task, but for some reason it does not work. The code drops all the variables, however it does not perform the cluster analysis as it tells me that the variable already exists. Why is this problem happening?
Thank you very much,
I am having issues with dropping a variable within the program I wrote. The code runs cluster analysis for different values of clusters. The prefix of the name of the generated grouping variables is given by the argument in the cluster_name. If the grouping variables already exists, I would like to drop them. I thought this was a straight forward task, but for some reason it does not work. The code drops all the variables, however it does not perform the cluster analysis as it tells me that the variable already exists. Why is this problem happening?
Thank you very much,
Code:
capture program drop kmeans_eval program define kmeans_eval syntax varlist, kmax(integer) cluster_name(string) local list2 `varlist' forvalues k = 1(1)`kmax' { capture drop `cluster_name'`k' } forvalues k = 1(1)`kmax' { cluster kmeans `list2', k(`k') start(random(123)) name(`cluster_name'`k') } end
Comment