Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Friedrich Huebler <fhuebler@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Some basic help on programming |

Date |
Wed, 11 Apr 2012 07:20:35 -0400 |

Prakash, I am going back to your first message, in which you had this code: use "level3_list.dta", clear keep if item_code==309 ren item_code item_code_manu ren asicc_code asicc_code_manu ren unit_quantity unit_quantity_manu ren quantity quantity_manu ren value value_manu sort common_id save "item309.dta",replace You can do the same with the commands below. The only difference is that variable names will have the code number instead of "manu", "trade", etc. use "level3_list.dta", clear local vars "item_code asicc_code unit_quantity quantity value" levelsof item_code, local(items) foreach i of local items { preserve keep if item_code==`i' foreach var of varlist `vars' { ren `var' `var'_`i' } sort common_id save "item`i'.dta", replace restore } Friedrich On Tue, Apr 10, 2012 at 11:06 PM, Prakash Singh <prakashbhu@gmail.com> wrote: > Thanks Maarten and Samuels > > I am providing here "tba" of one of the lavel data. Before that I > think I should explain about the dataset structure. this is firm level > data set. for convenience it is divided in levels. the present data > set contains 10 levels (for 82789 firm). in some of the level as in > the case of operating expences, asset, workers level data set needs to > be further divied into item to get information about female workers > (full time part time and temp) male worker (full time part time and > temp) but there is no distinct vatiable for these. > > we have single variable "value" in which represent different kind of > workers with item number (for example item number 301 represents > female full time worker, 302 female part time and son. now to get the > information at sub aggregate level var value has to be created at item > basis where each item repesent some particual of expences. > > > Item Freq. > 301 50,831 > 302 35,895 > 303 23,953 > 304 15,343 > 305 9,210 > 306 20,410 > 309 51,994 > 311 1,255 > 312 2,702 > 313 497 > 319 4,050 > Total 216,140 > > If you see the total it not equal to 82789. item 301 is female full > time worker and 50,831 represents the number of firms for which we > have information for female full time worker. thus in order to get the > value of total worker (male and female) we need to break the data at > item level and merge. > > I tried with collapse but values are differing with keep if method. > > Hope this will make my query clear. > > Prakash * * 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/

**Follow-Ups**:**Re: st: Some basic help on programming***From:*Prakash Singh <prakashbhu@gmail.com>

**References**:**st: Some basic help on programming***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: Some basic help on programming***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: Some basic help on programming***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: Some basic help on programming***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: Some basic help on programming***From:*Prakash Singh <prakashbhu@gmail.com>

- Prev by Date:
**Re: st: meanonly** - Next by Date:
**st: labels in -hbar- with over() and sort() specified** - Previous by thread:
**Re: st: Some basic help on programming** - Next by thread:
**Re: st: Some basic help on programming** - Index(es):