In that case i will continue to use the solution suggested by stata tech support which changes value labels before any matrices are created.
Change row name mat stata.
Matrcrename z col 4 sas column out of range r 498.
Matrcrename z col 3 some alternative.
I have never before however seen a stata matrix whose row or column names begin with digits.
No names informs stata whether variable names are included on the first line of the file roberto ferrer feb 7 16 at 23 54.
Computing column row means mat cm c rowsof a mat lis cm cm 1 2 c1 c2 r1 1 1 6666667 horizontal concatenation.
My final goal is a tab delimited text file that will be imported into a word processor to create a table like the one below.
The tricks and shortcuts mentioned were introduced with stata 12 0.
Row names of the form 1 n for n 2 are stored internally in a compact form which might be seen from c code or by deparsing but never via row names or attr x row names.
Transform the values to valid variable names strip out blanks invalid characters shorten load them into a macro variable.
If you load the mat file into a struct i e.
You can then save the struct back out to the mat file with the struct flag.
Mat li z symmetric z 3 3 x y z a 1 b 1 1 stata 1 1 1.
In contrast the question mark stands for a single character in a variable name.
Using stata mat c 2 1 5 1 3 4 5 4 2 mat lis c symmetric c 3 3 c1 c2 c3 r1 2 r2 1 3 r3 5 4 2 mat ct c mat lis ct symmetric ct 3 3 r1 r2 r3 c1.
Start reading at row 2 use the macro variable from step 1 after an input statement.
Which names matrix tokenize names local where newname local newnames matrix which names matrix newnames end examples.
Mat li z symmetric z 3 3 x y z a 1 b 1 1 c 1 1 1.
A quick review in the user manuals has not turned up anything to say that it is illegal but it is also clear from the text and all examples that stata matrix row and column names are often intended to match variable names and of course a variable name cannot.
See here note that stata won t let you name a variable 1960 1961 etc they can t begin with a number so i would go into the csv file or excel and manually rename them y1960 y1961 etc.
This will work at least this far.
Rename does not include the syntax variable unless that is a variable name.
Older versions of stata.
Row names is similar to rownames for arrays and it has a method that calls rownames for an array argument.
Read the first row.
The load option with output argument then your variables become fields of that struct which allows you to rename them renaming variables themselves is not a fun task.
Prior to that some other commands such as the following were available.
Both import excel and import delimited will let you specify that the first row contains variable names.