Hello,
I'm trying to write a simple ADO.
The idea is to write:
simple2 var1 var2 in order to create something as:
table var1, c(sum var2 count var2).
Always It was a goal to show messages if the user declared 1 or 3/4/5/...+ variables.
This is what I have:
The code inform you the weighted an unweighted table using the v1 as variable to tabulate, with v2 as iweight.
The code works if I declare 1 or 2 variables. The messages displays ok using only 1 variable on simple2.
However, If I declare 3 or more variables on simple2, I don't receive the alert. Simple2 just performs the following syntax:
table var1 [iw=var2]
Every variable after var2 doesn't matter to simple2.
The error comes from the count of elements_v.
But I can't fix it.
Can you guide me, please?
Thanks for your help and time.
I'm trying to write a simple ADO.
The idea is to write:
simple2 var1 var2 in order to create something as:
table var1, c(sum var2 count var2).
Always It was a goal to show messages if the user declared 1 or 3/4/5/...+ variables.
This is what I have:
HTML Code:
capture program drop simple2
program simple2
local variables `1' `2'
local elements_v: word count `variables'
if `elements_v'==2 {
table `1', c(sum `2' count `2')
}
else if `elements_v'=>3 {
display "You are using too many variables"
}
else if inrange(`elements_v',0,1) {
display "You are missing a variable/weight"
}
else {
}
The code works if I declare 1 or 2 variables. The messages displays ok using only 1 variable on simple2.
However, If I declare 3 or more variables on simple2, I don't receive the alert. Simple2 just performs the following syntax:
table var1 [iw=var2]
Every variable after var2 doesn't matter to simple2.
The error comes from the count of elements_v.
But I can't fix it.
Can you guide me, please?
Thanks for your help and time.

Comment