Hi ALL,
I am trying to convert the SPSS data into ASCII card data. I am using below code to convert it: GET FILE ='C:\Users\Gaurav S\Documents\Projects\Data Check\5687 - J&J Mega Tracker\Adult\HONGKONG\Data\p752065020_gsrivastava_20562058.sav'. WRITE OUTFILE = 'C:\Users\Gaurav S\Documents\Projects\Data Check\5687 - J&J Mega Tracker\Adult\HONGKONG\Data\DataCrd.dat' RECORDS=10 /1 RespID 1-6 (N) '01' 7-8 R1 9 R2 10-11 (N) Respondent_ID 12-62 (A) /2 RespID 1-6 (N) '02' 7-8 Q1 9 Q21 10 Q22 11 Q23 12 Q24 13 /3 RespID 1-6 (N) '03' 7-8 Data2 9-13 (comma,2) /4 RespID 1-6 (N) '04' 7-8 R1_01 11-12(N) R1_02 13-14(N) R1_03 15-16(N) R1_04 17-18(N) R1_05 19-20(N)R1_06 21-22(N)R1_07 23-24(N)R1_08 25-26(N)R1_09 27-28(N)R1_10 29-30(N)R1_99 31-32(N). Execute. It's working fine but it giving me a fixed width card ASCII data. I need the floating data file. Please help. I need it urgently. Regards, Gaurav |
Administrator
|
Perhaps you would be so kind and enlighten us to what you mean by a "floating data file"?
I have never heard that particular expression before in 30 years of doing data analysis ;-). I am not even going to attempt to apply my incomparable ESPss intuitions to second guess. Note FWIW: SPSS respects the ancient FORTRAN record specifications in case it helps. What the following shall convey is that you can (and should) instruct SPSS to place *ANY* variable into *ANY* location you desire in the output file (Fd.w,A,N,X etc). DATA LIST FREE / A B C D (4F). BEGIN DATA 1 2 3 4 end data STRING ALPHA (A8). COMPUTE alpha="abcdefgh". WRITE OUTFILE "C:\test1.txt" /A B C D (4(F8.3,1X/)). 1.000 2.000 3.000 4.000 WRITE OUTFILE "C:\test2.txt" /A alpha B alpha C alpha D alpha (4(F8.3,1X,A8/)). EXE. 1.000 abcdefgh 2.000 abcdefgh 3.000 abcdefgh 4.000 abcdefgh WRITE OUTFILE "C:\test3.txt" /A alpha B alpha C alpha D alpha (2(F8.3,1X,A8/N4,1X,A8/)). EXE. 1.000 abcdefgh 0002 abcdefgh 3.000 abcdefgh 0004 abcdefgh
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?" |
Hi David,
Thanks for your prompt reply. Let me brief you about floating data, may be it's not a right word which create confusion.
suppose I have a multi-response question with 1 to 10 categories and a respondent answer 1,2,4,6,8th categories. with my below code I can capture the data in ASCII at 1st, 2nd, 4th, 6th and 8th column position for this respondent.
Now I want to capture it straight at 1-5 column position without any blank (3rd and 5th in above case) which I am saying floating data. Hope this make it more clear. Please revert me ASAP. Regards,
Gaurav
On Wed, Mar 28, 2012 at 4:22 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: Perhaps you would be so kind and enlighten us to what you mean by a "floating data file"? |
Administrator
|
Please provide a very specific example of what the response pattern appears as in SPSS and what is required as output (are your source data numeric or strings, how wide etc...). My thoughts are to conditionally concatenate the MR fields to a single string and output the result.
Alternatively use the "power of 10" -or 100 as the case may be *YMMV after 10^16*. OTOH: I must decline much further comment without the down and dirty re your data. COMPUTE result=0. DO REPEAT v=v1 TO v10. IF NOT MISSING (v) result=result*10+v. END REPEAT. --
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?" |
Administrator
|
The string concatenation solution will be more direct!
DATA LIST /MR1 TO MR10 1-10. begin data 0011011101 1110110110 1100110011 end data. STRING MRCAT (A20). VECTOR M=MR1 TO MR10. LOOP #=1 TO 10. IF M(#) MRCAT=CONCAT(RTRIM(MRCAT),STRING(#,N2)). END LOOP. LIST. MR1 MR2 MR3 MR4 MR5 MR6 MR7 MR8 MR9 MR10 MRCAT 0 0 1 1 0 1 1 1 0 1 030406070810 1 1 1 0 1 1 0 1 1 0 01020305060809 1 1 0 0 1 1 0 0 1 1 010205060910
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 David Marso
Hi David,
I need the output data in quantum format. See the attached file.
1st 7 are resp IDs and next 3 are card number. I have also attached a dummy data file of SPSS data what I have. If you look into quantum output file row 14, all data are placed together, instead of data for 093 at 93 column number.
0000003004 093122094096126095127098108121102125105195107124104106
Hope it help. Please suggest! Regards, Gaurav
On Wed, Mar 28, 2012 at 5:06 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: Please provide a very specific example of what the response pattern appears as in SPSS and what is required as output (are your source data numeric or strings, how wide etc...). My thoughts are to conditionally concatenate the MR fields to a single string and output the result. |
In reply to this post by GauravSrivastava
do you start with multiple dichotomies?
I.e., to you have 10 yes/no questions of which the respondent could choose 5 (or was it "check all that apply")? That would be changing from multiple dichotomies to a multiple response arrangement. Art Kendall Social Research Consultants On 3/28/2012 7:16 AM, GauravSrivastava wrote: Hi 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
Art Kendall
Social Research Consultants |
it's check all that apply.
On Wed, Mar 28, 2012 at 5:31 PM, Art Kendall <[hidden email]> wrote:
|
Administrator
|
In reply to this post by GauravSrivastava
For free advice you need to make the example so transparent that I need only look at your stuff for about 2 minutes maximum to solve it. The attachments you sent are *NOT* such. Please simply and repost.
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 GauravSrivastava
Have you checked to see if Quantum will read an SPSS data file? Since SPSS owned both, it might have added this functionality to share data directly between the two programs. From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Gaurav Srivastava it's check all that apply. On Wed, Mar 28, 2012 at 5:31 PM, Art Kendall <[hidden email]> wrote: do you start with multiple dichotomies? Art Kendall Social Research Consultants
Hi David, Thanks for your prompt reply. Let me brief you about floating data, may be it's not a right word which create confusion. suppose I have a multi-response question with 1 to 10 categories and a respondent answer 1,2,4,6,8th categories. with my below code I can capture the data in ASCII at 1st, 2nd, 4th, 6th and 8th column position for this respondent. Now I want to capture it straight at 1-5 column position without any blank (3rd and 5th in above case) which I am saying floating data. Hope this make it more clear. Please revert me ASAP. Regards, Gaurav On Wed, Mar 28, 2012 at 4:22 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: Perhaps you would be so kind and enlighten us to what you mean by a "floating data file"? GauravSrivastava wrote Hi ALL, If you reply to this email, your message will be added to the discussion below: To unsubscribe from SPSS data file to ASCII card data file, click here. View this message in context: Re: SPSS data file to ASCII card data file |
In reply to this post by David Marso
Hi David,
Thanks for below suggestion. It working well. As I don't have much about vector. Can you help me on this:
STRING Q17_con (A50). VECTOR M=q17_001 to q17_025.
LOOP #=1 TO 237. IF M(#)
Q17_con =CONCAT(RTRIM(
Q17_con),STRING(#,N3)). END LOOP. LIST. Also My variables are not in sequential order. see my below variable list.
q17_001 q17_031 q17_002 q17_032 q17_003 q17_036 q17_004 q17_033 q17_005 q17_034 q17_006 q17_037 q17_007 q17_038 q17_008 q17_009 q17_010 q17_039 q17_011 q17_012 q17_035 q17_013 q17_041 q17_014 q17_040 q17_114 q17_140 q17_060 q17_090 q17_062 q17_063 q17_092 q17_064 q17_093 q17_122 q17_065 q17_094 q17_066 q17_096 q17_126 q17_067 q17_095 q17_127 q17_068 q17_097 q17_069 q17_098 q17_108 q17_121 q17_070 q17_073 q17_074 q17_099 q17_076 q17_102 q17_125 q17_077 q17_079 q17_103 q17_080 q17_105 q17_180 q17_195 q17_081 q17_107 q17_124 q17_104 q17_106 q17_025
While running the code it's capturing the order of variable listed in data. Can you suggest how can I put code (like 001,031,002,032 etc.) instead of order (001,002,003,004).
Hope it would be clear. Regards, Gaurav On Wed, Mar 28, 2012 at 4:22 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: Perhaps you would be so kind and enlighten us to what you mean by a "floating data file"? |
Administrator
|
REORDER your variables with /KEEP on the GET FILE.
Read up on VECTOR and LOOP in the manual... Putting my spoon away!
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 David Marso
Hi David,
Can we have this data in separate variable instead of concatenating it into MRCAT like below: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 030406070810 0102030506080910
010205060910 01020304050607080910 Please help! Regards, Gaurav On Wed, Mar 28, 2012 at 5:27 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: The string concatenation solution will be more direct! |
I’m not sure I quite understand what you want. But, does this read the data in the way that you need? data list /A1 A2 A3 A4 A5 A6 A7 A8 A9 A10(10f2.0). begin data 030406070810 0102030506080910 010205060910 01020304050607080910 end data. execute. Gene Maguin From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of GauravSrivastava Hi David, Can we have this data in separate variable instead of concatenating it into MRCAT like below: A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 030406070810 0102030506080910 010205060910 01020304050607080910 Please help! Regards, Gaurav On Wed, Mar 28, 2012 at 5:27 PM, David Marso [via SPSSX Discussion] <[hidden email]> wrote: The string concatenation solution will be more direct! David Marso wrote Please provide a very specific example of what the response pattern appears as in SPSS and what is required as output (are your source data numeric or strings, how wide etc...). My thoughts are to conditionally concatenate the MR fields to a single string and output the result. GauravSrivastava wrote Hi David, > Perhaps you would be so kind and enlighten us to what you mean by a > "floating data file"? > I have never heard that particular expression before in 30 years of doing > data analysis ;-). > I am not even going to attempt to apply my incomparable ESPss intuitions > to second guess. > Note FWIW: SPSS respects the ancient FORTRAN record specifications in case > it helps. > What the following shall convey is that you can (and should) instruct SPSS > to place *ANY* variable into *ANY* location you desire in the output file > (Fd.w,A,N,X etc). > DATA LIST FREE / A B C D (4F). > BEGIN DATA > 1 2 3 4 > end data > STRING ALPHA (A8). > COMPUTE alpha="abcdefgh". > WRITE OUTFILE "C:\test1.txt" /A B C D (4(F8.3,1X/)). > 1.000 > 2.000 > 3.000 > 4.000 > > WRITE OUTFILE "C:\test2.txt" /A alpha B alpha C alpha D alpha > (4(F8.3,1X,A8/)). > EXE. > > 1.000 abcdefgh > 2.000 abcdefgh > 3.000 abcdefgh > 4.000 abcdefgh > > WRITE OUTFILE "C:\test3.txt" /A alpha B alpha C alpha D alpha > (2(F8.3,1X,A8/N4,1X,A8/)). > EXE. > 1.000 abcdefgh > 0002 abcdefgh > 3.000 abcdefgh > 0004 abcdefgh > > GauravSrivastava wrote > Hi ALL, > > I am trying to convert the SPSS data into ASCII card data. I am using > below code to convert it: > > GET FILE ='C:\Users\Gaurav S\Documents\Projects\Data Check\5687 - J&J Mega > Tracker\Adult\HONGKONG\Data\p752065020_gsrivastava_20562058.sav'. > WRITE OUTFILE = 'C:\Users\Gaurav S\Documents\Projects\Data Check\5687 - > J&J Mega Tracker\Adult\HONGKONG\Data\DataCrd.dat' > RECORDS=10 > /1 RespID 1-6 (N) '01' 7-8 R1 9 R2 10-11 (N) Respondent_ID 12-62 (A) > /2 RespID 1-6 (N) '02' 7-8 Q1 9 Q21 10 Q22 11 Q23 12 Q24 13 > /3 RespID 1-6 (N) '03' 7-8 Data2 9-13 (comma,2) > /4 RespID 1-6 (N) '04' 7-8 R1_01 11-12(N) R1_02 13-14(N) R1_03 15-16(N) > R1_04 17-18(N) R1_05 19-20(N)R1_06 21-22(N)R1_07 23-24(N)R1_08 > 25-26(N)R1_09 27-28(N)R1_10 29-30(N)R1_99 31-32(N). > Execute. > > It's working fine but it giving me a fixed width card ASCII data. I need > the floating data file. > > Please help. I need it urgently. > > Regards, > Gaurav > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://spssx-discussion.1045642.n5.nabble.com/SPSS-data-file-to-ASCII-card-data-file-tp5599936p5600089.html > To unsubscribe from SPSS data file to ASCII card data file, click here< > . If you reply to this email, your message will be added to the discussion below: To unsubscribe from SPSS data file to ASCII card data file, click here. View this message in context: Re: SPSS data file to ASCII card data file |
Administrator
|
In reply to this post by GauravSrivastava
Please describe exactly what you are trying to do.
Maybe also better to create a new thread rather than resurrect a 9 month old one.
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?" |
Free forum by Nabble | Edit this page |