Data Transformation

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

Data Transformation

Deepanshu Bhalla
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Data Transformation

Edwin Meijdam-2
Hi,

Perhaps this helps:

DO REPEAT R=VAR00001 TO VAR00010.
DO IF (R > 1000 & R < 9999). 
- COMPUTE R=R - 1000.
ELSE IF (R > 9999 & R < 99999).
- COMPUTE R=R - 10000.
END IF.
END REPEAT.
EXECUTE.

hth,

Ed



On Wed, Jul 4, 2012 at 5:16 PM, Deepanshu Bhalla <[hidden email]> wrote:
Hi Team,

I have 10-12 numeric variables . Under these variables there are some
options, all of these options starting with 100 .. For example :
1002,10016,10014,1005 etc

I want to remove 100 from all these options . Like 1002 would be converted
to 2 , 10016 would be converted to 16 .. so on

I know this can be done using RECODE , IF THEN functions but these are a
little bit lengthy way to do this for 10-12 variables.

Is there any quick method to pull out 100 from multiple variables ?

Thanks in advance !

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Data-Transformation-tp5714009.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

Reply | Threaded
Open this post in threaded view
|

Re: Data Transformation

David Marso
Administrator
In reply to this post by Deepanshu Bhalla
DO REPEAT old=v1 TO v12 / new=x1 to x12.
COMPUTE new=MOD(old,100).
END REPEAT.


Deepanshu Bhalla wrote
Hi Team,

I have 10-12 numeric variables . Under these variables there are some options, all of these options starting with 100 .. For example : 1002,10016,10014,1005 etc

I want to remove 100 from all these options . Like 1002 would be converted to 2 , 10016 would be converted to 16 .. so on

I know this can be done using RECODE , IF THEN functions but these are a little bit lengthy way to do this for 10-12 variables.

Is there any quick method to pull out 100 from multiple variables ?

Thanks in advance !
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: Data Transformation

Art Kendall
In reply to this post by Deepanshu Bhalla
you should be able to adapt something like this.
It removes "100" in 2 ways.
Once in one compute.
then again laying out all of the steps.



new file.
data list list/longvar1 longvar2 (2f5).
begin data
1001 10012
10016 1002
10014 10014
1001 1002
10011 10010
end data.
*do it in one compute.
numeric oneliner1 to oneliner2(f2).
do repeat old=longvar1 to longvar2/
 one= oneliner1 to oneliner2.
compute one =number(replace(string(old,f5),"100",""),f2).
end repeat.
list.
* do it step by step.
string str1 to str2(a5).
string short1 to short2(a2).
numeric shortvar to shortvar2.
do repeat
 old  = longvar1 to longvar2/
  astr = str1 to str2/
 bstr = short1 to short2/
new  = shortvar1 to shortvar2.
compute astr= string(old,f5).
compute bstr= replace(astr,"100","").
compute new = number(bstr,f2).
end repeat.
list.

Art Kendall
Social Research Consultants
On 7/4/2012 11:16 AM, Deepanshu Bhalla wrote:
Hi Team,

I have 10-12 numeric variables . Under these variables there are some
options, all of these options starting with 100 .. For example :
1002,10016,10014,1005 etc

I want to remove 100 from all these options . Like 1002 would be converted
to 2 , 10016 would be converted to 16 .. so on

I know this can be done using RECODE , IF THEN functions but these are a
little bit lengthy way to do this for 10-12 variables.

Is there any quick method to pull out 100 from multiple variables ?

Thanks in advance !

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Data-Transformation-tp5714009.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Data Transformation

Deepanshu Bhalla
In reply to this post by Edwin Meijdam-2
CONTENTS DELETED
The author has deleted this message.