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: FW: How to compare file structure difference before append


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: FW: How to compare file structure difference before append
Date   Thu, 10 Jan 2013 10:42:12 +0000

It's programmable. You could probably get most of the way there by
using Roger Newson's -descsave- and then appending the results. I
haven't tried. Roger's files are in various places so -findit
descsave- to get locations.

Nick

On Thu, Jan 10, 2013 at 7:46 AM, rasool.bux <[email protected]> wrote:
> Thanks for reply and help. As per my experience in other softwares sometime the variable name is same but the type is different i.e. number or string, by appending that column comes blank if type is not matched.
>
> My intentions is to see the list of differences in the file structure as below.
> 1. # of variables matched and not matched in both files  (As -sfvars- doing)
> 2. list the type differences of matched variable names.
>         Variable        type/format in master           type/format in using
>
> So that we can look the values in both files and make the same before appending them.
>
> Thanks
> Rasool Bux
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: Thursday, January 10, 2013 3:13 AM
> To: [email protected]
> Subject: Re: st: FW: How to compare file structure difference before append
>
> You may be right. I was trying to answer the question that was asked, which often is wrong. But I think it usually takes a human to see that the same name is being applied to different things, or the same thing being named differently in different datasets.
>
> I had completely forgotten that I wrote -cfvars-, but Rasool's post just said "user-written". Now that it is mentioned, I can add that Rasool is correct. -cfvars- does only what it is intended to do.
>
> Nick
>
> On Wed, Jan 9, 2013 at 7:19 PM, Rebecca Pope <[email protected]> wrote:
>> -describe using- requires the user to spot the differences between the
>> current data and the listed output, correct? Maybe I'm reading too
>> much into the question but I thought Rasool was looking for a way have
>> Stata do the comparing. That's just my inference based off of the
>> reference to -cfvars-(1).
>>
>> -describe using- gave me an idea for a different approach though.
>> Here's a modification to what I posted earlier.
>>
>> *** begin ***
>> sysuse auto.dta, clear
>> preserve
>> tostring price, replace
>> save autodemocopy.dta, replace
>> describe , replace clear
>> tempfile foobar
>> save `"`foobar'"'
>> restore
>> preserve
>> describe, replace clear
>> merge 1:1 name type vallab varlab using `"`foobar'"'
>> list name type vallab varlab if _merge!=3 restore
>> *** end ***
>>
>> This checks format and labels. It could be modified to any attribute
>> that -describe- assesses. The -merge- can also be changed to keep only
>> records that conflict. I've left it like this so all original
>> variables still show up in "name" if the user wants to look at
>> everything.
>>
>> (1) Nicholas J. Cox, 2009. "CFVARS: Stata module to compare variable
>> name lists in two data sets," Statistical Software Components S457004,
>> Boston College Department of Economics.
>> http://ideas.repec.org/c/boc/bocode/s457004.html
>>
>> Rebecca
>>
>> On Wed, Jan 9, 2013 at 11:46 AM, Nick Cox <[email protected]> wrote:
>
>>> On 21 December I suggested -describe using-.
>>>
>>> http://www.stata.com/statalist/archive/2012-12/msg00790.html
>>>
>>> Nick
>>>
>>> On Wed, Jan 9, 2013 at 12:50 PM, rasool.bux <[email protected]> wrote:
>>>
>>>> I have seen user written program -cfvars- but it is just comparing variable names. Any suggestions.
>>>
>>>
>>>  -----Original Message-----
>>>> From: rasool.bux
>>>> Sent: Friday, December 21, 2012 11:17 AM
>>>> To: '[email protected]'
>>>> Subject: how to know the file structure difference before append
>>>
>>>> Is there any way to compare the dta file structure of two files to see the differences in varnames, types and formats?
>>>>
>>>> Then I want to use the append to combine the observations of both files.

*
*   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