Importing SAS Data into SPSS 19

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

Importing SAS Data into SPSS 19

Veena Nambiar
Hi All,

I am having issues with importing SAS data in SPSS 19 that I hope you can help me with. I had never encountered this issue in prior versions of SPSS.

 I use the following syntax to import the SAS file:
get sas data='path name.sas7bdat'.

I receive the following warning:
>Warning # 7254.  Command name: GET SAS
>One or more string data values contained invalid characters.  Any invalid
>characters were replaced by question marks.  If the source file originated in
>a different locale and if you are running in Unicode mode, you can specify an
>encoding with the ENCODING subcommand.

When I open the imported file, the file appears to be okay - no question marks.

However, for some reason, it is taking off exactly one character in one of the fields in the variable School Name. For example, the data is imported as this:

Aspire California College Preparatory A

Rather than this:

Aspire California College Preparatory Ac

The file was created in SAS with the appropriate width of 40 and when the person who created this file in SAS outputs the file in a different format, the data import into SPSS is fine.

Any ideas what the issue could be?

Thanks for your help!

Veena

=====================
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: Importing SAS Data into SPSS 19

Rick Oliver-3
From the GET SAS section of the help:

ENCODING Subcommand (GET SAS command)

The ENCODING subcommand specifies the character encoding of the SAS data file.

• The encoding must be correctly identified or the file cannot be read.

• If there is a formats files, the encoding of the formats file must be the same as the encoding of the data file. See the topic FORMATS Subcommand (GET SAS command) for more information.

• The subcommand is followed by an optional equals sign and a quoted encoding value.

• The quoted value can be any of the values in the Encoding column in the Character Encoding table or "UTF-8" for UTF-8 Unicode encoding.

• The default encoding is "Locale", which is the encoding of the current IBM® SPSS® Statistics locale. See the topic LOCALE Subcommand (SET command) for more information.

The help topic also includes a table of valid encoding values. This may involve a certain amount of trial and error if the person who supplied the file can't tell you the encoding. If it's SAS 9, it may be a Unicode (UTF-8) file.



From:        Veena Nambiar <[hidden email]>
To:        [hidden email]
Date:        07/11/2011 02:16 PM
Subject:        Importing SAS Data into SPSS 19
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Hi All,

I am having issues with importing SAS data in SPSS 19 that I hope you can help me with. I had never encountered this issue in prior versions of SPSS.

I use the following syntax to import the SAS file:
get sas data='path name.sas7bdat'.

I receive the following warning:
>Warning # 7254.  Command name: GET SAS
>One or more string data values contained invalid characters.  Any invalid
>characters were replaced by question marks.  If the source file originated in
>a different locale and if you are running in Unicode mode, you can specify an
>encoding with the ENCODING subcommand.

When I open the imported file, the file appears to be okay - no question marks.

However, for some reason, it is taking off exactly one character in one of the fields in the variable School Name. For example, the data is imported as this:

Aspire California College Preparatory A

Rather than this:

Aspire California College Preparatory Ac

The file was created in SAS with the appropriate width of 40 and when the person who created this file in SAS outputs the file in a different format, the data import into SPSS is fine.

Any ideas what the issue could be?

Thanks for your help!

Veena

=====================
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: Importing SAS Data into SPSS 19

Veena Nambiar

Hi Rick,


Thank you for the response. When you brought up the encoding issue, I realized under edit you can change the encoding option to Unicode rather than the locale’s writing system. For some reason, the encoding subcommand would not work in my syntax. The data come in properly when I changed to Unicode under options, however, the widths on the variables change. For instance, I brought in a variable that had a width of 14 in the original file and now the width is 42. I’m guessing the only way to deal with this is to specify the widths of the variables when importing the data or using the alter type command after importing to fix them.

 

Thank you for your help! I really appreciate it.

 

Veena

 

From: Rick Oliver [mailto:[hidden email]]
Sent: Monday, July 11, 2011 12:51 PM
To: Veena Nambiar
Cc: [hidden email]
Subject: Re: Importing SAS Data into SPSS 19

 

From the GET SAS section of the help:

ENCODING Subcommand (GET SAS command)

The ENCODING subcommand specifies the character encoding of the SAS data file.

• The encoding must be correctly identified or the file cannot be read.

• If there is a formats files, the encoding of the formats file must be the same as the encoding of the data file. See the topic FORMATS Subcommand (GET SAS command) for more information.

• The subcommand is followed by an optional equals sign and a quoted encoding value.

• The quoted value can be any of the values in the Encoding column in the Character Encoding table or "UTF-8" for UTF-8 Unicode encoding.

• The default encoding is "Locale", which is the encoding of the current IBM® SPSS® Statistics locale. See the topic LOCALE Subcommand (SET command) for more information.

The help topic also includes a table of valid encoding values. This may involve a certain amount of trial and error if the person who supplied the file can't tell you the encoding. If it's SAS 9, it may be a Unicode (UTF-8) file.



From:        Veena Nambiar <[hidden email]>
To:        [hidden email]
Date:        07/11/2011 02:16 PM
Subject:        Importing SAS Data into SPSS 19
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Hi All,

I am having issues with importing SAS data in SPSS 19 that I hope you can help me with. I had never encountered this issue in prior versions of SPSS.

I use the following syntax to import the SAS file:
get sas data='path name.sas7bdat'.

I receive the following warning:
>Warning # 7254.  Command name: GET SAS
>One or more string data values contained invalid characters.  Any invalid
>characters were replaced by question marks.  If the source file originated in
>a different locale and if you are running in Unicode mode, you can specify an
>encoding with the ENCODING subcommand.

When I open the imported file, the file appears to be okay - no question marks.

However, for some reason, it is taking off exactly one character in one of the fields in the variable School Name. For example, the data is imported as this:

Aspire California College Preparatory A

Rather than this:

Aspire California College Preparatory Ac

The file was created in SAS with the appropriate width of 40 and when the person who created this file in SAS outputs the file in a different format, the data import into SPSS is fine.

Any ideas what the issue could be?

Thanks for your help!

Veena

=====================
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: Importing SAS Data into SPSS 19

mrose@benrose.org
In reply to this post by Veena Nambiar
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Importing SAS Data into SPSS 19

Jon K Peck
In reply to this post by Veena Nambiar
Converting to Unicode always triples the field width, which is in bytes, to allow for the worst case expansion of the text.  You can use the ALTER TEXT command to reset the width(s) to the minimum required to hold the Unicode data.

HTH,

Jon Peck
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Veena Nambiar <[hidden email]>
To:        [hidden email]
Date:        07/12/2011 12:19 AM
Subject:        Re: [SPSSX-L] Importing SAS Data into SPSS 19
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi Rick,

Thank you for the response. When you brought up the encoding issue, I realized under edit you can change the encoding option to Unicode rather than the locale’s writing system. For some reason, the encoding subcommand would not work in my syntax. The data come in properly when I changed to Unicode under options, however, the widths on the variables change. For instance, I brought in a variable that had a width of 14 in the original file and now the width is 42. I’m guessing the only way to deal with this is to specify the widths of the variables when importing the data or using the alter type command after importing to fix them.

 
Thank you for your help! I really appreciate it.
 
Veena
 
From: Rick Oliver [mailto:oliverr@...]
Sent:
Monday, July 11, 2011 12:51 PM
To:
Veena Nambiar
Cc:
[hidden email]
Subject:
Re: Importing SAS Data into SPSS 19

 
From the GET SAS section of the help:

ENCODING Subcommand (GET SAS command)

The ENCODING subcommand specifies the character encoding of the SAS data file.

• The encoding must be correctly identified or the file cannot be read.

• If there is a formats files, the encoding of the formats file must be the same as the encoding of the data file. See the topic FORMATS Subcommand (GET SAS command) for more information.

• The subcommand is followed by an optional equals sign and a quoted encoding value.

• The quoted value can be any of the values in the Encoding column in the Character Encoding table or "UTF-8" for UTF-8 Unicode encoding.

• The default encoding is "Locale", which is the encoding of the current IBM® SPSS® Statistics locale. See the topic LOCALE Subcommand (SET command) for more information.

The help topic also includes a table of valid encoding values. This may involve a certain amount of trial and error if the person who supplied the file can't tell you the encoding. If it's SAS 9, it may be a Unicode (UTF-8) file.



From:        
Veena Nambiar <VNambiar@...>
To:        
[hidden email]
Date:        
07/11/2011 02:16 PM
Subject:        
Importing SAS Data into SPSS 19
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>







Hi All,

I am having issues with importing SAS data in SPSS 19 that I hope you can help me with. I had never encountered this issue in prior versions of SPSS.

I use the following syntax to import the SAS file:
get sas data='path name.sas7bdat'.

I receive the following warning:
>Warning # 7254.  Command name: GET SAS
>One or more string data values contained invalid characters.  Any invalid
>characters were replaced by question marks.  If the source file originated in
>a different locale and if you are running in Unicode mode, you can specify an
>encoding with the ENCODING subcommand.

When I open the imported file, the file appears to be okay - no question marks.

However, for some reason, it is taking off exactly one character in one of the fields in the variable School Name. For example, the data is imported as this:

Aspire California College Preparatory A

Rather than this:

Aspire California College Preparatory Ac

The file was created in SAS with the appropriate width of 40 and when the person who created this file in SAS outputs the file in a different format, the data import into SPSS is fine.

Any ideas what the issue could be?

Thanks for your help!

Veena

=====================
To manage your subscription to SPSSX-L, send a message to

LISTSERV@... (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