Hello, I have a 6 digit numerical variable X and i want to create a new variable Y that will consists of the last two digits of X. Var X does not have any decimals.
Could someone help? thanks so much. bozena X Y 196012 12 194509 09 etc |
The obvious function is Modulus, Y= mod(X, 100).
If I haven't reversed the arguments. You won't see a leading 0 on "09" for a simple numeric variable unless you print it with N2 format. -- Rich Ulrich Date: Tue, 24 Apr 2012 23:55:21 +0000 From: [hidden email] Subject: trimming a numerical variable To: [hidden email] Hello, I have a 6 digit numerical variable X and i want to create a new variable Y that will consists of the last two digits of X. Var X does not have any decimals. Could someone help? thanks so much. bozena X Y 196012 12 194509 09 etc |
Administrator
|
Just confirming Rich's suggestion.
data list list / X (f6.0). begin data 196012 194509 end data. compute Y = mod(x,100). formats y (n2.0). list. OUTPUT: X Y 196012 12 194509 09 Number of cases read: 2 Number of cases listed: 2
--
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/). |
I am out of the office until February 15. For immediate assistance please contact Jessica Jaramillo ([hidden email]). Thank you. |
Administrator
|
"I am out of the office until February 15."
2013? or are you into time travel? It would be nice if some people would UNSUBSCRIBE! --
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?" |
In reply to this post by Bruce Weaver
thanks so much to all that responded!
bozena ________________________________________ From: SPSSX(r) Discussion [[hidden email]] on behalf of Bruce Weaver [[hidden email]] Sent: Wednesday, April 25, 2012 6:28 AM To: [hidden email] Subject: Re: trimming a numerical variable Just confirming Rich's suggestion. data list list / X (f6.0). begin data 196012 194509 end data. compute Y = mod(x,100). formats y (n2.0). list. OUTPUT: X Y 196012 12 194509 09 Number of cases read: 2 Number of cases listed: 2 Rich Ulrich-2 wrote > > The obvious function is Modulus, Y= mod(X, 100). > If I haven't reversed the arguments. > > You won't see a leading 0 on "09" for a simple > numeric variable unless you print it with N2 format. > > -- > Rich Ulrich > > Date: Tue, 24 Apr 2012 23:55:21 +0000 > From: bozena.zdaniuk@ > Subject: trimming a numerical variable > To: SPSSX-L@.UGA > > > > > > > > Hello, I have a 6 digit numerical variable X and i want to create a new > variable Y that will consists of the last two digits of X. Var X does not > have any decimals. > > Could someone help? > > thanks so much. > > bozena > > > > X Y > > 196012 12 > > 194509 09 > > etc > ----- -- 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/trimming-a-numerical-variable-tp5663595p5664863.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 |