• United States
IBM?
  • Site map
IBM? developerWorks   Developer Centers
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
dW Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

developerWorks

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.206

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

Splitting one variable into two variables

310001XQTF gravatar image
Question by BISWAJITKAR  (1) | Feb 25, 2016 at 01:37 AM spssstatisticssyntax

Respected users, I want to split one string variable into two variables. The string variable (master variable) contain 6 digits maximum. Now I want one variable of first 3 digits from master variable and another variable containing last 3 digits without effecting the other variables. Please suggest me any path.

Thanks and regards, Biswajit

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

1 reply

  • Sort: 
270003YJRM gravatar image

Answer by David Dwyer (56) | Feb 26, 2016 at 10:58 AM

@BISWAJITKAR,

This is something that can be handled in the GUI under the "Transform -> Compute" menus. In the Compute dialog you will want to create two new variables of the appropriate type and then assign a portion of your original variable to each of these. Assuming you have a string field to start with, you might use the CHAR.SUBSTR(strvar,start,length) function to parse it. You could also do this in SPSS Statistics Command Syntax.

Assuming your original variable "master" is a 6 character string field, here is an example creating two 3 character string fields "left" and "right" with the leftmost and rightmost 3 characters from "master" respectively:

 DATA LIST FREE /master (A6).
 BEGIN DATA
 abcdef ghijkl mnopqr stuvwx
 END DATA.
 LIST.
 STRING left right (A3).
 COMPUTE left = CHAR.SUBSTR(master,1,3).
 COMPUTE right = CHAR.SUBSTR(master,4).
 LIST.
 

Comment
Susan Magilton

People who like this

  1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

50 people are following this question.

Show
Hide
310001XQTF gravatar image
270000GWTC gravatar image
270000FDR4 gravatar image
270000XYBA gravatar image
110000716N gravatar image
270006XPGB gravatar image
12000089VF gravatar image
270007S0YR gravatar image
0 gravatar image
270000HCSB gravatar image
270007J4V5 gravatar image
060000TPFC gravatar image
270007TC7S gravatar image
270007N89G gravatar image
270007E13S gravatar image
270003G2C2 gravatar image
2700077Y16 gravatar image
060000GS8A gravatar image
27000412BP gravatar image
270003TDDU gravatar image
110000A7Q4 gravatar image
2700002Q84 gravatar image
2700019D3F gravatar image
0600026V6R gravatar image
270007KSPS gravatar image
120000GKJX gravatar image
270005CRQH gravatar image
270002DX0R gravatar image
1100006DS0 gravatar image
120000PKE0 gravatar image
2700071CQ3 gravatar image
060000JCQ6 gravatar image
120000KBJ0 gravatar image
2700048B8W gravatar image
2700077GBQ gravatar image
270001KHBU gravatar image
310000C3WF gravatar image
120000FVD3 gravatar image
2700078CT8 gravatar image
120000DJQR gravatar image
110000CPVN gravatar image
100000PUHW gravatar image
060000UPGT gravatar image
270005EH6S gravatar image
270002YGE4 gravatar image
120000K2Y8 gravatar image
31000066QG gravatar image
27000417SH gravatar image
310001NSJK gravatar image
270003YJRM gravatar image

Answers

Answers & comments

Related questions

Output Export Problem 3 Answers

How to use custom dialog variable list in CTABLES /TABLE subcommand 2 Answers

bugs in SPSS22? 9 Answers

How to send a email in spss? 9 Answers

Entering a date into a save file name 3 Answers

  • Contact
  • Privacy
  • Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • DataPower
  • Decision Optimization
  • DevOps Services
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Storage
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges