Dear experts,
For the following repeated codes :
tab1 variable1 if (variableA == 1) & (variableB== 1), missing
tab1 variable1 if (variableA == 1) & (variableB== 1) & (variableC== 1), missing
tab1 variable1 if (variableA == 1) & (variableB== 1) & (variableD== “no reason”), missing
tab1 variable2 if (variableA == 1) & (variableB== 1), missing
tab1 variable2 if (variableA == 1) & (variableB== 1) & (variableC== 1), missing
tab1 variable2 if (variableA == 1) & (variableB== 1) & (variableD== “no reason”), missing
tab1 variable3 if (variableA == 1) & (variableB== 1), missing
tab1 variable3 if (variableA == 1) & (variableB== 1) & (variableC== 1), missing
tab1 variable3 if (variableA == 1) & (variableB== 1) & (variableD== “no reason”), missing
…….
…….
If I repeat doing the same above for variable1, variable2, variable3……variable6
Other than using macro below, is there any more efficient way? e.g. using loop?
Thank you for help.
local repeat variable1 variable2 variable3 variable4 variable5 variable6
tab1 `repeat’ if (variableA == 1) & (variableB== 1), missing
tab1 `repeat’ if (variableA == 1) & (variableB== 1) & (variableC== 1), missing
tab1 `repeat’ if (variableA == 1) & (variableB== 1) & (variableD== “no reason”), missing
Related Posts with Efficient Way to Reform Repeated Codes with IF condition
egen command is only generating missingsHello, i used the egen in previous data anlysis and it worked pretty well. The code looked somehti…
Coding a new categorical variable based on an existing categorical variableHi Statalist. I would like to create a few groups based on some of the categories of an existing va…
Plotting Quantile treatment effects with 95% confidence intervalDear statalist, I am using the following code to plot the QTE along with 95 % CI. capture postuti…
capture a change over time within idHi I have a panel data of N couples (id) over 6 time periods the variable h_child is equal to "1" if…
How to change the width of bars in a catplot graphHello everyone, I generated a bar graph using the catplot command for two categorical variables and…
Subscribe to:
Post Comments (Atom)
0 Response to Efficient Way to Reform Repeated Codes with IF condition
Post a Comment