Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: simple data input question- expanding macros


From   Scott Kostyshak <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: simple data input question- expanding macros
Date   Fri, 15 Aug 2008 11:48:32 -0700

"Please don't do that. If the question is too elementary or trivial to
ask, don't post it. If not, you need not apologise. If you call it the
wrong way, the world will not end for you. "

I apologize for saying that.. haha sorry, I couldn't resist. That is a good point, I will not apologize for my questions in the future.


"The key problems about a beginners' list include: Who would set it up?"
Perhaps the same people that set this list up. Subscribing could be as simple as this statalist, but instead it would be statalist-beginners

"What about cross-posting?"
cross-posting is, indeed annoying. Hopefully people would send their message out to one list or the other. Maybe after a week of it not being answered, the poster could send it to the other list.

"Who would answer the questions?"
The same people here; and, me, once I learn more. Why would this be any different than any other forum (which often has a beginners section)? Do you think that most of the subscribers already on this statalist would not subscribe to the beginners statalist? Although in my economist training I have been taught to think that people are selfish, I actually think people love helping. I already have 4 interesting replies to my question. Or, we can say that people are selfish and have an interest in helping people learn Stata (this is a stretch, I admit)- the more people that use Stata, the more incentives the company will have to continue upgrading Stata with new features.

"Also, who "quite is a beginner? I don't think that any Stata "expert" is not also a complete ignoramus on large chunks of Stata, nor is anybody claiming otherwise."
Good point. Well perhaps then, it wouldn't be a statalist for beginners but rather beginner-type questions. Maybe even "experts" would send a beginner question from time to time.

Also, what is a simple question? The poster here thought they
had a simple question, but I think it's fair from simple. (I'll answer
separately.) "
Excellent point. If you don't know something, it's difficult to know if it's hard or not. Perhaps in this case I erroneously said it was simple. However, I think people are usually decently placed to know whether their question is easy or not.

"I don't have easy answers, nor do I say it's impossible, but no
beginners' list is in sight."
That's OK, I'll survive :)


"Those who program should make it possible for the rest of you not to do so. It's particularly unfortunate if people get the impression that each task requires a new program to automate it. Stata really shouldn't be that difficult!"
I thought about this statement for awhile. In some sense, I agree with you: simple tasks should have simple methods of performing them. However, I think that programming is inevitable no matter how skilled Stata programmers are. If they tried to make a command for everything that someone would want to do, think what a mess Stata would be!
I like your point, though, that one should first work interactively until he is comfortable and then can move on to programming.
My problem is that I know how to program in another language (Perl). And, there are so many times when something would be so easy to do in Perl, but with Stata, it is not (for me, at least). This frustrates me, but I think that one learns programming only through frustration.


Thank you VERY much for your time and comments, Nick. I consider them a "welcome to statalist" :)

Below is an email that I sent that did not go through (addressed, in particular, to Martin Weiss and Maarten Buis); hopefully this one will.

Best, Scott

> From: [email protected]
> To: [email protected]
> Subject: RE: st: RE: simple data input question- expanding macros
> Date: Fri, 15 Aug 2008 03:49:03 -0700
>
>
> Martin Weiss,
>
> Good question about why I would want to make things complicated. I should have stated in my question that I was trying to give a simple example of what I really wanted to do. In my program I process a lot of data and then end up with some values stored in macros that I need to make a new dataset out of. Perhaps there is a better way, but I am still getting used to the Stata style of programming, which I would say is extremely different than in conventional languages (or maybe I just think that because I have not learned enough of Stata yet).
>
> I did not know about _rc, that seems like it will be a useful thing to remember in the future.
>
>
> Maarten Buis,
>
> that is exactly what I was looking for. Thank you! I was trying to think of a way of doing something like that (I was going to do --input--, then input whatever as observations just to expand the number and replace them after), but I doubt I would have been able to come up with anything as good as your "solution". tokenize definitely seems useful for this application.
>
>
> Thank you both for the replies!
>
> Scott
>
>
>
>
> Maybe the following is what you want? See -help extended_fcn- and
> -help tokenize- for more details.
>
> *----------- begin example ---------------
> clear
> local colors "red blue yellow"
> local n : word count `colors'
> set obs `n'
> gen colors = ""
> tokenize `colors'
> forvalues i = 1/`n' {
> replace colors = "``i''" in `i'
> }
> *----------- end example -----------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
> Hope this helps,
> Maarten
>
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
>
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room Z434
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
>
>
>> From: [email protected]
>> To: [email protected]
>> Subject: st: RE: simple data input question- expanding macros
>> Date: Fri, 15 Aug 2008 10:54:54 +0200
>>
>> This raises questions on several levels. If the -local- does not do the job,
>> the -global- probably won`t fix that. Omit the equal sign which is
>> unnecessary. See the following for an example of what happens:
>>
>> *******
>> local color "red"
>> cap di `color'
>> di _rc
>> di "`color'"
>> *******
>>
>> On another level, why do you not paste the strings into the data editor?
>> Your approach to entering data seems unusual and horribly complicated...
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> [email protected]
>> Sent: Friday, August 15, 2008 10:35 AM
>> To: [email protected]
>> Subject: st: simple data input question- expanding macros
>>
>> Hi, I apologize for such a simple question. I hope to eventually participate
>> in statalist on a much higher level.
>>
>> I would like to input data that I have in strings manually in a .do file.
>> That is, say I have a for loop going through a list of a bunch of strings,
>> how can I use those strings to input data?
>>
>> Say, I have a macro called color.
>> and, I have an existing dataset with blue and green as observations (there
>> is only one variable, COL).
>> Why doesn't the following work:
>>
>> local color = "red"
>> input
>> `color'
>> end
>>
>> I tried the above code using a global variable as well, to no avail:
>>
>> global color = "red"
>> input
>> ${color}
>> end
>>
>>
>> Is there a better way to do this? How do I expand my macro before anything
>> else happens?
>>
>> Thank you!
>>
>> PS. is there any good forum online that might be better for beginner
>> questions?

_________________________________________________________________
Get thousands of games on your PC, your mobile phone, and the web with Windows�.
http://clk.atdmt.com/MRT/go/108588800/direct/01/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index