Any help would be great! I imported a huge file (about 550,000) entries
into SPSS. The last column, which is in date form of "11/05/05" did not get copied in correctly. It shows up ,11/05/05. An extra comma in the front of the entry. Does anyone know how I can get the comma to be erased? There are so many rows (550,000+) that I do not want to reimport, and have no clue how I can remove these commas. Any help is appreciated! |
All,
I am missing soemthing here. In writing from SPSS to fixed ASCII, my employee number variabel 8 columns, numeric ends up being written in scientific notation. When I go back to the SPSS data set and convert the column to string in hopes of writing the numebr out a s a string, SPSS converts the column into an 8 digit number with a value followd by a string of seven 0s. This is a recent install of 14 (with patch) so I am thinking that I haven't reset an option correctly. Any ideas other than writing the file to Excel and then writing it out in fixed ASCII? Mark *************************************************************************************************************************************************************** Mark A. Davenport Ph.D. Senior Research Analyst Office of Institutional Research The University of North Carolina at Greensboro 336.256.0395 [hidden email] 'An approximate answer to the right question is worth a good deal more than an exact answer to an approximate question.' --a paraphrase of J. W. Tukey (1962) |
In reply to this post by Randi-3
Hope this helps :
Compute DateVar = Replace(DateVar,",",""). Regards. Edward. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Randi Sent: Wednesday, October 25, 2006 10:23 AM To: [hidden email] Subject: Removing partial data from variable Any help would be great! I imported a huge file (about 550,000) entries into SPSS. The last column, which is in date form of "11/05/05" did not get copied in correctly. It shows up ,11/05/05. An extra comma in the front of the entry. Does anyone know how I can get the comma to be erased? There are so many rows (550,000+) that I do not want to reimport, and have no clue how I can remove these commas. Any help is appreciated! |
In reply to this post by Randi-3
Randi,
I'm going to assume that your current date variable (Date) is A9 format and that you want an A8 format with the comma deleted. String newdate(a8). Compute newdate=substr(date,2,8). Gene Maguin |
Randi,
Gene's solution works perfectly but don't forget the EXECUTE. command after the COMPUTE statement. *************************************************************************************************************************************************************** Mark A. Davenport Ph.D. Senior Research Analyst Office of Institutional Research The University of North Carolina at Greensboro 336.256.0395 [hidden email] 'An approximate answer to the right question is worth a good deal more than an exact answer to an approximate question.' --a paraphrase of J. W. Tukey (1962) Gene Maguin <[hidden email]> Sent by: "SPSSX(r) Discussion" <[hidden email]> 10/25/2006 11:53 AM Please respond to Gene Maguin <[hidden email]> To [hidden email] cc Subject Re: Removing partial data from variable Randi, I'm going to assume that your current date variable (Date) is A9 format and that you want an A8 format with the comma deleted. String newdate(a8). Compute newdate=substr(date,2,8). Gene Maguin |
In reply to this post by Mark A Davenport MADAVENP
Try explicitly setting the format of the variable prior to writing to the external file. For an 8-digit integer, for example:
formats varname (F8). -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark A Davenport MADAVENP Sent: Wednesday, October 25, 2006 10:31 AM To: [hidden email] Subject: Writing to fixed ASCII All, I am missing soemthing here. In writing from SPSS to fixed ASCII, my employee number variabel 8 columns, numeric ends up being written in scientific notation. When I go back to the SPSS data set and convert the column to string in hopes of writing the numebr out a s a string, SPSS converts the column into an 8 digit number with a value followd by a string of seven 0s. This is a recent install of 14 (with patch) so I am thinking that I haven't reset an option correctly. Any ideas other than writing the file to Excel and then writing it out in fixed ASCII? Mark *************************************************************************************************************************************************************** Mark A. Davenport Ph.D. Senior Research Analyst Office of Institutional Research The University of North Carolina at Greensboro 336.256.0395 [hidden email] 'An approximate answer to the right question is worth a good deal more than an exact answer to an approximate question.' --a paraphrase of J. W. Tukey (1962) |
In reply to this post by Mark A Davenport MADAVENP
At 11:53 AM 10/25/2006, Gene Maguin had written
>I'm going to assume that your current date >variable (Date) is A9 format and >that you want an A8 format with the comma deleted. > >String newdate(a8). >Compute newdate=substr(date,2,8). At 12:07 PM 10/25/2006, Mark A Davenport MADAVENP responded: >Gene's solution works perfectly but don't forget >the EXECUTE. command after the COMPUTE statement. Actually, please do forget it. EXECUTE is not needed to make a transformation effective. It's a very common misperception that it is (I think I know why), but it can be harmful. EXECUTE forces a complete read of the data file, so it can take a lot of extra time with a big file. (The original inquiry was about a big file.) For discussion of EXECUTE, see "Use EXECUTE sparingly" in any edition of Raynald Levesque's book(*), or more postings of mine than I care to count. (*) Levesque, Raynald, "SPSS® Programming and Data Management, 2nd Edition/A Guide for SPSS® and SAS® Users". SPSS, Inc., Chicago, IL, 2005; Levesque, Raynald, and SPSS Inc., "SPSS® Programming and Data Management, 3rd Edition/A Guide for SPSS® and SAS® Users". SPSS, Inc., Chicago, IL, 2005. You can download the third edition free as a PDF file, from http://www.spss.com/spss/SPSS_programming_data_mgmt.pdf. I don't know whether the second edition is still available for download. The third edition includes a lot on Python programming. For any SPSS version before 14, the second edition will be at least as good. |
In reply to this post by Maguin, Eugene
At 11:53 AM 10/25/2006, Gene Maguin wrote:
>>The last column, which is in date form of "11/05/05" shows up [as] >>",11/05/05". >I'm going to assume that your current date variable (Date) is A9 >format and that you want an A8 format with the comma deleted. > >String newdate(a8). >Compute newdate=substr(date,2,8). Exactly so. However, you also might want the date as an SPSS date variable; it's often the most useful form. To make a date variable that *displays* mm/dd/yy (not *is* mm/dd/yy - date variables have no inherent format), NUMERIC newdate (ADATE8). COMPUTE newdate=NUMBER(substr(date,2),ADATE8). (Not tested) |
Free forum by Nabble | Edit this page |