save translate

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

save translate

Samuel Solomon
Hi all,
 
SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
for instance:
1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?  
2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?
 
thanks,
Samuel.

====================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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

Oliver, Richard
Using the Keep subcommand you can change the variable order. If you have SPSS 15 or later, you can also specify the delimiter for CSV format files:

data list free /x y z.
begin data
1 2 3
end data.
save translate outfile='c:\temp\temp.csv'
 /type=csv /textoptions delimiter=';'
 /keep z y x /replace.

In earlier releases, you can use the Write command instead of Save Translate to create a text file with semicolons between values:

write outfile='c:\temp\temp.txt'
 /z ";" y ";" x.
execute.


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Samuel Solomon
Sent: Wednesday, November 21, 2007 7:16 AM
To: [hidden email]
Subject: save translate

Hi all,

SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
for instance:
1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?
2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?

thanks,
Samuel.

=======
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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

Marta Garcia-Granero
In reply to this post by Samuel Solomon
Hi

> SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
> for instance:
> 1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?
> 2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?
>

Although you already got an answer (concerning the semi-colons), this
one tells you how towrite a header to make the exported data star at row #4:

* Some sample data to work with *.
DATA LIST LIST/var1 var2 var3 var4 var5 (5 F1).
BEGIN DATA
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
END DATA.

* Export data to text with a 3 line header *.
DO IF $casenum EQ 1.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /'This is the first row of the header'
 /'This is the second row of the header'
 /'This is the third (followed by a CR)'
 /''.
END IF.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /var1 ';' var2 ';' var3 ';' var4 ';' var5.
EXE.

Best regards,
Marta García-Granero

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

ViAnn Beadle
In reply to this post by Samuel Solomon
If you want the variable names in the middle of the rows of data, it's
probably easier to just move it there from within Excel.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Samuel Solomon
Sent: Wednesday, November 21, 2007 6:16 AM
To: [hidden email]
Subject: save translate

Hi all,

SPSS can translate '.sav' file format to other machine readable formats,
applauds for that but can it go any further; provide you control over the
positions where you want to put cases in the 'outfile' subcommand.
for instance:
1. if I want to put cases including variable names in the third or fourth
raw in the desired, tab delimited, xls formats, what would you suggest?
2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the
secret?

thanks,
Samuel.

=======
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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

Oliver, Richard
In reply to this post by Marta Garcia-Granero
Ah, I read the initial query too quickly and totally missed what was being asked for in #1. I read "control over position" and immediately interpreted that as order of variables. In the case of needing to control the starting row number for the exported data, then saving the a text data file with Write is probably the only viable option. As an alternative to Marta' solution:

data list free /x y z.
begin data
1 2 3
end data.
do if $casenum=1.
*write variable names in row 4.
write outfile='c:\temp\temp.txt'
  /4 'x;y;z'.
end if.
*append case data to open file, starting in next available row.
write outfile='c:\temp\temp.txt'
 /x ';' y ';' z.
execute.

But all of these methods overwrite the file if it exists. They cannot be used to insert data at a certain point in an existing file while preserving any information in the existing file that may exist prior to the start point or after the end point of the data.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
Sent: Wednesday, November 21, 2007 8:44 AM
To: [hidden email]
Subject: Re: save translate

Hi

> SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
> for instance:
> 1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?
> 2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?
>

Although you already got an answer (concerning the semi-colons), this
one tells you how towrite a header to make the exported data star at row #4:

* Some sample data to work with *.
DATA LIST LIST/var1 var2 var3 var4 var5 (5 F1).
BEGIN DATA
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
END DATA.

* Export data to text with a 3 line header *.
DO IF $casenum EQ 1.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /'This is the first row of the header'
 /'This is the second row of the header'
 /'This is the third (followed by a CR)'
 /''.
END IF.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /var1 ';' var2 ';' var3 ';' var4 ';' var5.
EXE.

Best regards,
Marta García-Granero

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

Hal 9000
Hi,
Based on my experience, I have to agree with Viann. Get it into Excel
first (preferably on its own sheet) and then use formulae (vlookups or
direct cell references) to make the right data appear in the right
cell.
Good Luck,
Gary

On Nov 21, 2007 7:08 AM, Oliver, Richard <[hidden email]> wrote:

> Ah, I read the initial query too quickly and totally missed what was being asked for in #1. I read "control over position" and immediately interpreted that as order of variables. In the case of needing to control the starting row number for the exported data, then saving the a text data file with Write is probably the only viable option. As an alternative to Marta' solution:
>
> data list free /x y z.
> begin data
> 1 2 3
> end data.
> do if $casenum=1.
> *write variable names in row 4.
> write outfile='c:\temp\temp.txt'
>   /4 'x;y;z'.
> end if.
> *append case data to open file, starting in next available row.
> write outfile='c:\temp\temp.txt'
>  /x ';' y ';' z.
> execute.
>
> But all of these methods overwrite the file if it exists. They cannot be used to insert data at a certain point in an existing file while preserving any information in the existing file that may exist prior to the start point or after the end point of the data.
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
> Sent: Wednesday, November 21, 2007 8:44 AM
> To: [hidden email]
>
> Subject: Re: save translate
>
> Hi
>
> > SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
> > for instance:
> > 1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?
> > 2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?
> >
>
> Although you already got an answer (concerning the semi-colons), this
> one tells you how towrite a header to make the exported data star at row #4:
>
> * Some sample data to work with *.
> DATA LIST LIST/var1 var2 var3 var4 var5 (5 F1).
> BEGIN DATA
> 1 2 3 4 5
> 2 3 4 5 6
> 3 4 5 6 7
> 4 5 6 7 8
> END DATA.
>
> * Export data to text with a 3 line header *.
> DO IF $casenum EQ 1.
> WRITE OUTFILE='C:\Temp\Exported.txt'
>  /'This is the first row of the header'
>  /'This is the second row of the header'
>  /'This is the third (followed by a CR)'
>  /''.
> END IF.
> WRITE OUTFILE='C:\Temp\Exported.txt'
>  /var1 ';' var2 ';' var3 ';' var4 ';' var5.
> EXE.
>
> Best regards,
> Marta García-Granero
>
> =====================
> 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
>

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: save translate

Samuel Solomon
In reply to this post by Oliver, Richard
hi everyone,
Thanks all! problem solved. I am still way way behind when it comes spss versions. Mine is ver.11.0.
thanks again,
Samuel.

________________________________

From: SPSSX(r) Discussion on behalf of Oliver, Richard
Sent: Wed 11/21/2007 6:08 PM
To: [hidden email]
Subject: Re: save translate



Ah, I read the initial query too quickly and totally missed what was being asked for in #1. I read "control over position" and immediately interpreted that as order of variables. In the case of needing to control the starting row number for the exported data, then saving the a text data file with Write is probably the only viable option. As an alternative to Marta' solution:

data list free /x y z.
begin data
1 2 3
end data.
do if $casenum=1.
*write variable names in row 4.
write outfile='c:\temp\temp.txt'
  /4 'x;y;z'.
end if.
*append case data to open file, starting in next available row.
write outfile='c:\temp\temp.txt'
 /x ';' y ';' z.
execute.

But all of these methods overwrite the file if it exists. They cannot be used to insert data at a certain point in an existing file while preserving any information in the existing file that may exist prior to the start point or after the end point of the data.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero
Sent: Wednesday, November 21, 2007 8:44 AM
To: [hidden email]
Subject: Re: save translate

Hi

> SPSS can translate '.sav' file format to other machine readable formats, applauds for that but can it go any further; provide you control over the positions where you want to put cases in the 'outfile' subcommand.
> for instance:
> 1. if I want to put cases including variable names in the third or fourth raw in the desired, tab delimited, xls formats, what would you suggest?
> 2. if I want to delimit cases by ' ;' in the outfile subcommand, what is the secret?
>

Although you already got an answer (concerning the semi-colons), this
one tells you how towrite a header to make the exported data star at row #4:

* Some sample data to work with *.
DATA LIST LIST/var1 var2 var3 var4 var5 (5 F1).
BEGIN DATA
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
END DATA.

* Export data to text with a 3 line header *.
DO IF $casenum EQ 1.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /'This is the first row of the header'
 /'This is the second row of the header'
 /'This is the third (followed by a CR)'
 /''.
END IF.
WRITE OUTFILE='C:\Temp\Exported.txt'
 /var1 ';' var2 ';' var3 ';' var4 ';' var5.
EXE.

Best regards,
Marta García-Granero

=====================
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

====================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