On Mon, 20 Jan 2014, Leandro Zipitria wrote:
Dear Gretl users,
I have a dataset that have 200 variables, all by the name prod_# (that is,
a list of products from 1 to 200). I also have a csv with the description
of that product (oil, ham, etc.).
Is there any (simple) way of adding the information of each product to the
description of the variable by reading the csv file? I know that it could
be done "by hand" by editing each variable and copy and paste on the
description of the variable.
Example (your case may vary somewhat):
$ cat prod.txt
prod_1 prod_2 prod_3
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
$ cat pnames.txt
oil
ham
eggs
$ cat descrips.inp
open prod.txt
string D = readfile("pnames.txt")
string line
scalar i = 1
loop while getline(D, line) -q
setinfo i --description="@line"
i++
endloop
labels
On running descrips.inp I get:
? labels
Listing labels for variables:
prod_1: oil
prod_2: ham
prod_3: eggs
Allin Cottrell