Hi all,
Can someone help me solve the following: I am looking write a loop to set each string variable equal to the max length of each string.
I imagine I'll need the ds command. I've tried to use the strlenght command and local the format as %`X's. Not having much luck on that.Any ideas on how I could do that?
Here's a more detailed description:
Suppose I have a dataset and I use the ds, has(type string). From there, I'm trying to write a loop that goes through each variable in `r(varlist)' and formats each variable equal to the maximum length. I can do this manually, using the strlen function and then formatting the variable using %s. Can anyone think of a way to do this in one loop without too much mess.
Thanks all.
Can someone help me solve the following: I am looking write a loop to set each string variable equal to the max length of each string.
I imagine I'll need the ds command. I've tried to use the strlenght command and local the format as %`X's. Not having much luck on that.Any ideas on how I could do that?
Here's a more detailed description:
Suppose I have a dataset and I use the ds, has(type string). From there, I'm trying to write a loop that goes through each variable in `r(varlist)' and formats each variable equal to the maximum length. I can do this manually, using the strlen function and then formatting the variable using %s. Can anyone think of a way to do this in one loop without too much mess.
Thanks all.
Comment