Dear all, I have a, perhaps very basic, question on looping over several variables, but I couldn't find anything online that fits my problem. In my application, I have a long list of variables which all have the same prefix “var_”, followed by some numbers. However, it is not a simple integer count, but something “non-predictable” like var_1003, var_1250, var_2510, var_2950, … data test; input id var_1003 var_1250 var_2510 var_2950; datalines; 1 50 . 250 40 2 . 40 . . 3 100 200 . 30 ; For each variable, I want to perform the same operation and generate a new variable which includes the name of the old variable. For example, say for each variable "var_..." I want to generate an indicator “missvar_...” =1 if the variable is missing and =0 if it is not missing: if var_1003=. then missvar_1003=1; else missvar_1003=0; if var_1250=. then missvar_1250=1; else missvar_1250=0; … Is there any way to automate this for all variables without having to specify each variable separately? Any help is greatly appreciated. Thank you!
... View more