My question is about the write.foreign() command in the foreign package. I use a command like the following to try and output data and a code file to read my data into SAS. write.foreign(data.frame.object, datafile="filepath", codefile="filepath", package="SAS", dataname="myData") With my data set, it gives the following error: Error in make.SAS.names(names(df), validvarname = validvarname) : Cannot uniquely abbreviate the variable names to 32 or fewer characters I tried to write reproducible code but could not. I'm not sure where to go from here. What are the naming protocols for variables so that they can be exported using write.foreign()? Thanks! Andrew Miles
Nordlund, Dan (DSHS/RDA)
2010-Oct-20 17:18 UTC
[R] Problem exporting data using write.foreign
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Andrew Miles > Sent: Wednesday, October 20, 2010 10:10 AM > To: r-help at r-project.org > Subject: [R] Problem exporting data using write.foreign > > My question is about the write.foreign() command in the foreign > package. I use a command like the following to try and output data > and a code file to read my data into SAS. > > write.foreign(data.frame.object, datafile="filepath", > codefile="filepath", package="SAS", dataname="myData") > > With my data set, it gives the following error: > > Error in make.SAS.names(names(df), validvarname = validvarname) : > Cannot uniquely abbreviate the variable names to 32 or fewer > characters > > I tried to write reproducible code but could not. I'm not sure where > to go from here. What are the naming protocols for variables so that > they can be exported using write.foreign()? > > Thanks! > > Andrew Miles >Well, the error message tells you that the names must be unique when truncated to 32 characters. Apparently, you have at least 2 variables that have the same name when truncated to 32 characters. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204