change case on variable labels

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

change case on variable labels

wsu_wright
I have a sp file that has mixed case variable labels (e.g., Last_name).
I need to change the case on all variable labels to upper case (e.g.,
LAST_NAME).  We are performing some oracle based bulk inserts & the
program we're using wants the column names to be upper case.  Didn't
know if this was possible via straight syntax, no python please.  Thanks
in advance.

David

=====================
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: change case on variable labels

Bruce Weaver
Administrator
David, do you mean that you have something like this

variable labels
 v1 "First_name"
 v2 "Last_name"
 v3 "Age"
 v4 "Sex"
.

...and you want it to look like this?

VARIABLE LABELS                                            
 V1 "FIRST_NAME"                                            
 V2 "LAST_NAME"                                            
 V3 "AGE"                                                  
 V4 "SEX"                                                  
.            

If so, you could simply copy the relevant syntax into Word, and use Format-Change Case to change to uppercase, then paste back into your syntax file.  

Alternatively, you could read the entire syntax file into SPSS (via GET DATA), use UPCASE to change everything to uppercase, then write it back out to a syntax file with WRITE OUTFILE.  E.g.,

GET DATA
  /TYPE=TXT
  /FILE="C:\Temp\MySyntax.sps"
  /FIXCASE=1
  /ARRANGEMENT=FIXED
  /FIRSTCASE=1
  /IMPORTCASE=ALL
  /VARIABLES=
  /1 V1 0-59 A60.
CACHE.
EXECUTE.

* Depending on the length of your lines of syntax, you may
* need to alter the number of columns & formatting for V1 above.

COMPUTE V1 = UpCase(v1).
WRITE OUTFILE = "C:\Temp\MySyntaxUpCase.sps" / v1 .
EXECUTE.

The Pythonistas will probably find this terribly old-school, but it works.  ;-)

HTH.


David Wright-6 wrote
I have a sp file that has mixed case variable labels (e.g., Last_name).
I need to change the case on all variable labels to upper case (e.g.,
LAST_NAME).  We are performing some oracle based bulk inserts & the
program we're using wants the column names to be upper case.  Didn't
know if this was possible via straight syntax, no python please.  Thanks
in advance.

David

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

Re: change case on variable labels

Lemon, John S.
In reply to this post by wsu_wright
David

I'd do it the 'easy' way and copy it to Word, use the UPPERCASE option in that and paste it back !! - I've done it that way a number of times

Best Wishes

John S. Lemon
DIT ( Directorate of Information Technology ) - Student Liaison Officer
University of Aberdeen
Edward Wright Building: Room G86a
Tel:  +44 1224 273350

DIT news for Students

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wright
Sent: 07 March 2012 21:29
To: [hidden email]
Subject: change case on variable labels

I have a sp file that has mixed case variable labels (e.g., Last_name).
I need to change the case on all variable labels to upper case (e.g., LAST_NAME).  We are performing some oracle based bulk inserts & the program we're using wants the column names to be upper case.  Didn't know if this was possible via straight syntax, no python please.  Thanks in advance.

David

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


The University of Aberdeen is a charity registered in Scotland, No SC013683.

=====================
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: change case on variable labels

David Marso
Administrator
In reply to this post by wsu_wright
What is an "sp" file?
"the program we're using wants the column names to be upper case."
What info does it use to interface SPSS with ORACLE?
Since when are "table names" reliably/sanely built from "Variable Labels"?  If this is the case then are you sure you are not referring to "Variable names"
Variable labels in SPSS can be *QUITE LONG* and more importantly *DO NOT HAVE TO BE UNIQUE*.  If indeed you are referring to Variable Labels then the grand scheme is more than likely FUBAR bound!
Finally, I'm having difficulty encoding this as an SPSS question!
--
David Wright-6 wrote
I have a sp file that has mixed case variable labels (e.g., Last_name).
I need to change the case on all variable labels to upper case (e.g.,
LAST_NAME).  We are performing some oracle based bulk inserts & the
program we're using wants the column names to be upper case.  Didn't
know if this was possible via straight syntax, no python please.  Thanks
in advance.

David

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

Re: change case on variable labels

wsu_wright
In reply to this post by wsu_wright
Thanks Bruce & John.  After I saw your post I saw that the solution was
staring me in the face.  I have the original syntax for this spss file
so it was easy as you suggested to simply pull in the variable names in
Word & make the case change. It's not necessary for our spss users and
is a small pain to make the change but for our non-spss users &
reporting services which use our oracle databases we have to upload our
spss files to the database which we do via syntax (using the syntax from
the export database wizard) and this normally goes smoothly.  But for
our larger files we need to do bulk inserts (otherwise it would take
hours for the load).  In both the MS sql server & oracle server
environments, this requires us to export the spss file as a csv which is
then uploaded via a format file on the sql side for bulk inserting.  On
the MS sql server side, mixed case variable names are not a problem but
on the oracle side the batch utility our dba uses requires upper case.
Thanks again for your help as always...


On Wed, Mar 7, 2012 at 4:22 PM, Bruce Weaver wrote:

> David, do you mean that you have something like this
>
> variable labels
>  v1 "First_name"
>  v2 "Last_name"
>  v3 "Age"
>  v4 "Sex"
> .
>
> ...and you want it to look like this?
>
> VARIABLE LABELS
>  V1 "FIRST_NAME"
>  V2 "LAST_NAME"
>  V3 "AGE"
>  V4 "SEX"
> .
>
> If so, you could simply copy the relevant syntax into Word, and use
> Format-Change Case to change to uppercase, then paste back into your
> syntax
> file.
>
> Alternatively, you could read the entire syntax file into SPSS (via
> GET
> DATA), use UPCASE to change everything to uppercase, then write it
> back out
> to a syntax file with WRITE OUTFILE.  E.g.,
>
> GET DATA
>   /TYPE=TXT
>   /FILE="C:\Temp\MySyntax.sps"
>   /FIXCASE=1
>   /ARRANGEMENT=FIXED
>   /FIRSTCASE=1
>   /IMPORTCASE=ALL
>   /VARIABLES=
>   /1 V1 0-59 A60.
> CACHE.
> EXECUTE.
>
> * Depending on the length of your lines of syntax, you may
> * need to alter the number of columns & formatting for V1 above.
>
> COMPUTE V1 = UpCase(v1).
> WRITE OUTFILE = "C:\Temp\MySyntaxUpCase.sps" / v1 .
> EXECUTE.
>
> The Pythonistas will probably find this terribly old-school, but it
> works.
> ;-)
>
> HTH.
>
>
>
> David Wright-6 wrote
>>
>> I have a sp file that has mixed case variable labels (e.g.,
>> Last_name).
>> I need to change the case on all variable labels to upper case (e.g.,
>> LAST_NAME).  We are performing some oracle based bulk inserts & the
>> program we're using wants the column names to be upper case.  Didn't
>> know if this was possible via straight syntax, no python please.
>> Thanks
>> in advance.
>>
>> David
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>> LISTSERV@.UGA (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
>>
>
>
> -----
> --
> Bruce Weaver
> [hidden email]
> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> View this message in context:
> http://spssx-discussion.1045642.n5.nabble.com/change-case-on-variable-labels-tp5545717p5545808.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