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

Re: st: implementing a pattern to match numbers with ranges

From   "Eva Poen" <[email protected]>
To   [email protected]
Subject   Re: st: implementing a pattern to match numbers with ranges
Date   Sat, 13 Sep 2008 17:03:28 +0100


if your assignment from SIC to industry codes follow some standard,
you might be lucky in that someone may have written a package to do
the assignment for you. I did a quick search on SIC in Stata, but
didn't find anything. Maybe there is something on the internet.

If that fails, you'll have to recode yourself. Assuming that your SIC
variable is numeric, I'd recommend the inrange() function.

gen Industry = .
format Industry  %02.0f

replace Industry = 3 if inrange(SIC,100,799) | SIC==2048


Hope this helps,

2008/9/13 - <[email protected]>:
> Dear all,
> I have many numbers with 4 digits, like 0100, 2044,... (this variable is
> called "SIC"). Now I want to match this number to a two-digit number (this
> new variable is called "Industry").
> The matching should be like this:
>       0100-0799,2048-2048=03
>       2000-2046,2050-2063,2070-2079,2090-2095,2098-2099=23
>       2064-2068,2086-2087,2096-2097=47
>       2080-2085='08'
> One example: variable "SIC" is given with the value 0100. Then Stata should
> give variable "Industry" the value 03 for this row.
> I am looking for a way to implement this pattern. I hope there is someone
> with an idea...
> Thanks a lot,
> Silke R.
*   For searches and help try:

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