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 |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: data import/varname problem |

Date |
Wed, 11 Jul 2012 11:22:53 +0100 |

Evaluating names using = will cause long lists of names to be truncated. You could just copy local mymac `r(varlist)' or use e.g. -unab- to put unabbreviated names straight into a macro. insheet using ... unab wanted : * insheet using ... unab actual : * rename (`actual') (`wanted') Nick n.j.cox@durham.ac.uk Scott Merryman Something like this: . insheet using "C:\Users\scott.merryman\Desktop\variablenames.csv", clear (3 vars, 0 obs) . ds aaa bbb ccc . local name =r(varlist) . insheet using "C:\Users\scott.merryman\Desktop\data.csv", clear (3 vars, 2 obs) . l +--------------+ | v1 v2 v3 | |--------------| 1. | 1 2 3 | 2. | 4 5 6 | +--------------+ . ds v1 v2 v3 . local a= r(varlist) . rename (`a') (`name') . ds aaa bbb ccc . l +-----------------+ | aaa bbb ccc | |-----------------| 1. | 1 2 3 | 2. | 4 5 6 | +-----------------+ Scott On Tue, Jul 10, 2012 at 1:43 PM, Jeph Herrin <stata@spandrel.net> wrote: > I have a dataset that comes to me in two files. Both are comma separated > files: one is the header (list of variable names) and the other is the data. > My problem is to combine the two, so that I have variable names on the data. > > If the files were smaller, I would probably just open both in Excel and > insert the single row in the header file onto the top row of the data file, > save, and then -insheet- the result into Stata. However in this case the > number of columns (329) exceeds the maximum allowed by Excel. A second > option would be to use a text editor to insert the header on the top line, > but the dataset is almost 5GB, and even -vim- seems to be choking on it (it > crashes after 5 or so minutes, something I have never seen -vim- do before). > > I can -insheet- both files into Stata, so I have two Stata datasets, one > containing data and the other containing variable names. But, having done > that, I can't figure out a way to use the latter to name the variables in > the former. > > Any tricks I'm missing? This is US government issued data, so I can't ask > for a more intelligent delivery arrangement. > * * 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/

**References**:**st: data import/varname problem***From:*Jeph Herrin <stata@spandrel.net>

**Re: st: data import/varname problem***From:*Scott Merryman <scott.merryman@gmail.com>

- Prev by Date:
**st: Update to -stjmgraph- on SSC** - Next by Date:
**Re: st: change default date base (1 jan 1960)** - Previous by thread:
**Re: st: data import/varname problem** - Next by thread:
**st: Standardization necessary for mediation analysis with binary outcome? About binary_mediation ado** - Index(es):