Sunday, November 13, 2011

No Strings Attached

On a cold Sunday evening, starting from the evening until well past midnight, it has taken me more than 7 hours to figure out why a simple code would not run. I checked the data, I looked up Google, I emailed the professor, I posted a new thread of message in the class discussion forum. However, nothing worked. I could not generate a simple bar graph using two variables in stata. I took breaks, I paced up and down my home, I sometimes sipped some water. The assignment was due the following day, and the professor had promised it shouldn’t take that long. Then why was the code not working?

After seven plus hours of thinking, contemplating, frowning, agonizing, staring at the data, seeking for help, excogitating, and cerebrating, I finally spotted the problem. Every numeric information I had in my dataset, stata for some inexplicable reason thought was a string data. Now why would stata think an achievement score percentile would be string data, I have no idea. Some serious googling indicated that string data was coded red, and numeric data was coded black. With the sinking feeling, I went back to my dataset and checked. There was blood everywhere.

All it took me was a simple command, “destring, replace”. Within seconds, stata had converted most variables from red to black. There are a few that still look red, but I am past caring.

I cried the moment stata converted everything from red to black. I don’t know if the tears were for happiness, relief, or tension release.

I cried, because it took me seven plus hours on a Sunday evening to figure out that every numeric data was being read as string data. And all it took to fix it was a simple command. Whether I am stupid, naïve, or lack sharpness to survive graduate school, I will never know. This could be one of your unfortunate evenings if you were in graduate school. If you are interested in graduate school, please ensure that you have virtues like patience, hard work, and persistence in your toolkit.

Finally, my data looks as if there are no strings attached.

sunshine

4 comments:

Biddu said...

Similar things have happened to me on frequent occasions while using MATLAB, so it's not a new thing...and that's why sometimes i feel good coders can conquer the world..but then great men like the professors and accomplished researchers differ on this opinion as they think that it is the problem solving ability that matters and not the tools (i.e., coding) that you use to solve it...anyway good luck with your assignments!

Philotics said...

I have been there so many times that I gave up caring for them. I think coding in general taught me more Gita (reference below). It is hard, but try not to attach any emotion with coding. If something's not right, it's not right, however flawless you might think it is.


Nuggets of Gita: "You have a right to perform your prescribed action,but you are not entitled to the fruits of your action.
Never consider yourself the cause of the results your activities,and never be associated to not doing your duty."
(Translated from Sanskrit:-"Karmanye Vadhikaraste Ma Phaleshu Kadachana,
Ma Karma Phala Hetur Bhurmatey Sangostva Akarmani")

Richa said...

Oh God! I so relate to this. It has happened to me so many times. Usually after few hours of struggle I used to call my best friend in grad school and explain the problem to her. That always helped me.

I usually spotted the problem while explaining to her or she would suggest some simple test to run which almost always helped (for some reason, I am incapable of thinking simple when I am working on a problem). There have been rare times when nothing worked and I simply went to sleep. tried the next day. Again on the day after. I can proudly say that it never took more than a week to spot a problem.

Wait, did I just say proudly...oh well, you need to be in grad school to appreciate that statement.

maxdavinci said...

haha find me one grad student who hasn't been in a similar situation and I'll show you god!