makecols(x,var1,var2, ... [,keyword phrases]), where x is a REAL matrix, var1, var2, ... unquoted or quoted variable names makecols(x,vector("var1","var2", ... ) [,keyword phrases]) makecols(x [,keyword phrases]), x a REAL matrix with labels. makecols(charx,var1,var2, ... [,keyword phrases]), charx a CHARACTER scalar or vector makecols(charx,vector("var1","var2", ... ) [,keyword phrases]) makecols(charx [,keyword phrases]), first line of charx containing variable names Keyword phrases are factors:facVec, nomissing:T, quiet:T or silent:T, facVec a LOGICAL vector or vector of positive integers |

makecols(x,name_1,...,name_k), where x is a REAL matrix and name_1, ..., name_k are unquoted or quoted variable names, creates new REAL vectors name_1, name_2, ... from the columns of x. You can think of makecols() as a sort of inverse to hconcat(). If a name which is not a quoted string is the name of an existing variable, only the name is used, not the value of variable. A report is printed of the variables created. It's OK for the number of names to differ from the number of columns in x. When there are more names than columns, the extras are ignored. When there are more columns than names, the final columns are ignored. makecols(x,vector("name_1","name_2",...,"name_k") [keyword phrases]) is an alternative usage. makecols(x,name_1,...,name_k, factors:facVec) does the same, but specifies that some of the columns of x are to be saved as factors. facVec can be a vector of positive integer column numbers or a LOGICAL vector of length k. When facVec contains integers, they are the columns of x to be saved as factors. When facVec is LOGICAL, column i of x is saved as a factor only if facVec[i] is True. For example, when x has 4 columns, both makecols(x,a,b,c,y,factor:run(3)) and makecols(x,a,b,c,y, factor:vector(T,T,T,F) saves columns 1, 2 and 3 of x as factors a, b and c and column 4 of x as REAL vector y. You can use keyword 'factors' with any other keyword. makecols(charx,name_1,...,name_k), where charx is a CHARACTER scalar or vector does the same, except the data to be saved is obtained as vecread(string:charx, fields:T) (see subtopic vecread:"reading_from_ character_variable"). makecols(charx) does the same, provided the first line of CHARACTER scalar or vector charx consists of a list of legal MacAnova names. An important special case of a CHARACTER first argument is makecols(CLIPBOARD, name_1, ... [,factors:TorFvec). You could use this when you have copied a data matrix to the clipboard, perhaps in a spread sheet program. makecols(CLIPBOARD [,factors:TorFvec[) would be appropriate when the first line of the selection copied contained column headings to be used as variable names. See topic 'CLIPBOARD'. makecols(x,name_1,...,name_k,quiet:T) does the same, except no report is printed. makecols(x,name_1,...,name_k,silent:T) does the same, except nothing is printed, not even warning messages. 'quiet:T' and 'silent:T' can always be used, no matter how names are specified. makecols(x,name_1,...,name_k,nomissing:T) does the same except any MISSING values are removed from the variables created. If all the elements in a column of x are MISSING, the corresponding variable is NULL. A warning message is printed unless 'silent:T' is an argument. 'nomissing:T' can always be used, no matter how names are specified. makecols(x), with no names provided, is legal when x has labels. It is equivalent to makecols(x,getlabels(x2)), and creates variables using the column labels as names. See topics 'labels', getlabels(). The first argument can also be a CHARACTER scalar or vector such as CLIPBOARD; see below. Example: Cmd> makecols(x, x1, x2, x3, x4) Cmd> makecols(x,"x1","x2","x3","x4") Cmd> makecols(x, vector("x1","x2","x3","x4"), quiet:T) These all create vectors x1, x2, x3 and x4 from the first 4 columns of x. All but the last print a report that these vectors were created Cmd> makecols(x, x1, x2, x3, x4, nomissing:T,silent:T) This does the same except x1, ..., x4 will have no MISSING values, with no report and any warning messages suppressed. Cmd> makecols(data,a,b,c,y,factors:run(3)) Cmd> makecols(data,a,b,c,y,factors:vector(T,T,T,F) These both save columns 1, 2 and 3 of data as factors a, b and c and column 4 as vector y. Cmd> makecols(vector("1 2","3 4"),x,y)# makecols(" 1 2\n 3 4", x, y) Cmd> makecols(vector("x y","1 2","3 4"))# makecols("x y\n 1 2\n 3 4") These both create vectors x and y of length 2 by "reading" the CHARACTER first argument. makecols() is implemented as a pre-defined macro. See also topics readcols(), clipreaddata(), hconcat().

Gary Oehlert 2003-01-15