|
I have merged two SPSS data files in R and created file in SPSS format (.sav). But in a process of exporting data from R to SPSS the variables format (i.e. width and decimal place) has got changed.
e.g. VAR1 has format of F8.5 in both SPSS data files and merged the files in R. While exporting the data from R to SPSS format of the variable VAR1 is F8.2 only. Is there any option to get exact format of the variable VAR1 (F8.5) while exporting data from R to SPSS? Or SPSS syntax to fix the format of the variables by default. |
|
Administrator
|
I can't help you with exporting from R to SPSS. But in case you don't know, the formats you are talking about are just display formats--they do not affect the stored values. If you need the display format for VAR1 to be F8.5 for some reason, just use a FORMATS command when opening that data file.
GET FILE = "C:\MyFolder\DataFromR.sav". FORMATS VAR1 (F8.5). HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
Administrator
|
Also, if you have all numeric data and want them all to have 5 decimals you can use
FORMATS ALL (F8.5). ===
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
Administrator
|
Aye, good point! Or if you have ranges of all numeric variables in your data set, you can use the keyword TO between the first and last numeric variables in a range.
FORMATS v1 TO v8 v11 TO v18 v21 TO v28 (F8.5) It's all in the FM (aka., the Command Syntax Reference manual). Help > Command Syntax Reference.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
|
In reply to this post by Dandu Sridhar
What do you expect the format to be in R? R variables do not have specific formats, only types such as "double" or "character", which correspond to Statistics "numeric" or "string" types. BTW, you can read R data frames from the R workspace directly using the STATS GET R extension command. On Tue, Mar 1, 2016 at 2:58 AM, Dandu Sridhar <[hidden email]> wrote: I have merged two SPSS data files in R and created file in SPSS format |
|
In reply to this post by Dandu Sridhar
Why do the merge in R?
under <help> see MATCH FILES. Another way to get help is to type the procedure name with a period (here "MATCH FILES.") in a syntax window, place your cursor on the text and key <f1> or <help>.
Art Kendall
Social Research Consultants |
|
In reply to this post by Dandu Sridhar
If a format is not declared, the default
format for numeric variables in SPSS Statistics is 8.2.
You can change the format for any variable with the FORMATS command, as in: FORMATS somevar (F8.5). If you want 8.5 to be the default for numeric variables: SET FORMAT 8.5. Note that the full value of numeric variables is retained regardless of the defined numeric format. data list free /x (f8.2). begin data 1 1.1 1.12 1.123 1.1234 end data. list. formats x (f8.5). list. Rick Oliver Senior Information Developer IBM Business Analytics (SPSS) E-mail: [hidden email] From: Dandu Sridhar <[hidden email]> To: [hidden email] Date: 03/02/2016 08:10 AM Subject: To fix format of the variables Sent by: "SPSSX(r) Discussion" <[hidden email]> I have merged two SPSS data files in R and created file in SPSS format (.sav). But in a process of exporting data from R to SPSS the variables format (i.e. width and decimal place) has got changed. e.g. VAR1 has format of F8.5 in both SPSS data files and merged the files in R. While exporting the data from R to SPSS format of the variable VAR1 is F8.2 only. Is there any option to get exact format of the variable VAR1 (F8.5) while exporting data from R to SPSS? Or SPSS syntax to fix the format of the variables by default. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/To-fix-format-of-the-variables-tp5731641.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
