Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Wishlist for Stata 13


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Wishlist for Stata 13
Date   Wed, 30 Jan 2013 10:30:53 +0100

On Wed, Jan 30, 2013 at 7:23 AM, Chamara Anuranga wrote:
> 1. I prefer when generate or replace variable on the dataset the
> command attach as a different type of note to the dataset. This option
> should be set off and on in order to reduce the file size.

You don't have to wait for StataCorp to do this for you. Here are two
programs that do what you ask. If you don't want the notes, than just
use -generate- and -replace- instead of -mygen- and -myreplace-.

*! version 1.0.0 30Jan2013 MLB
program define mygen
	generate `0'
	
	// find the name of variable
	gettoken x rest : 0
	local type "byte int long float double"
	if `: list x in type' {
		gettoken x : rest
	}
	gettoken x : x, parse("=")
	gettoken x : x, parse(":")
	
	// add note
	note `x' : generate `0'
end

*! version 1.0.0 30Jan2013 MLB
program define myreplace
	replace `0'
	
	// find the name of variable
	gettoken x rest : 0
	local type "byte int long float double"
	if `: list x in type' {
		gettoken x : rest
	}
	gettoken x : x, parse("=")
	
	// add note
	note `x' : replace `0'
end

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index