Dear Statalist,
I wish to store the values of a variable as scalars if a string-condition is fulfilled.
My dataset looks something like this and consists of one numeric and one string variable.
system value
a 6
b 5
c 10
d 10
So in this case, I wish to generate totally 4 scalars, accordingly:
if system=="a" {
scalar a=value
}
if system=="b" {
scalar b=value
}
if system=="c" {
scalar c=value
}
if system=="d" {
scalar d=value
}
However, it seems that Stata only stores the first scalar.
scalar list
a = 6
My scalar list should look like this:
a = 6
b = 5
c = 10
c = 10
Any suggestions?
I wish to store the values of a variable as scalars if a string-condition is fulfilled.
My dataset looks something like this and consists of one numeric and one string variable.
system value
a 6
b 5
c 10
d 10
So in this case, I wish to generate totally 4 scalars, accordingly:
if system=="a" {
scalar a=value
}
if system=="b" {
scalar b=value
}
if system=="c" {
scalar c=value
}
if system=="d" {
scalar d=value
}
However, it seems that Stata only stores the first scalar.
scalar list
a = 6
My scalar list should look like this:
a = 6
b = 5
c = 10
c = 10
Any suggestions?
Comment