Get Data format when reading in a 400 variable CSV file

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

Get Data format when reading in a 400 variable CSV file

Art Kendall
I know I have come across this before but cannot remember how I did it before.

SPSS does not like the format in the GET DATA below.

*create file with 400 variables to see if SPSS can read a 400 variable CSV file.
new file.
input program.
   vector x (400,f3).
   loop id = 1 to 3.
      loop #p = 1 to 400.
         compute x(#p) = rnd(rv.normal(50,10)).
      end loop.
      end case.
   end loop.
   end file.
end input program.
SAVE TRANSLATE OUTFILE='C:\project\test400.csv'
  /TYPE=CSV
  /ENCODING='Locale'
  /MAP
  /REPLACE
  /FIELDNAMES
  /CELLS=VALUES.
GET DATA  /TYPE=TXT
  /FILE="C:\project\test400.csv"
  /ENCODING='Locale'
  /DELCASE=LINE
  /DELIMITERS=","
  /ARRANGEMENT=DELIMITED
  /FIRSTCASE=2
  /IMPORTCASE=ALL
  /VARIABLES= x1 to x400 (400f2.0).
CACHE.
EXECUTE.


-- 
Art Kendall
Social Research Consultants
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Get Data format when reading in a 400 variable CSV file

Rick Oliver-3
I don't think GET DATA recognizes the "TO" convention. You have to explicitly declare each variable and a format for each variable.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Art Kendall <[hidden email]>
To:        [hidden email],
Date:        08/13/2013 03:43 PM
Subject:        Get Data format when reading in a 400 variable CSV file
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I know I have come across this before but cannot remember how I did it before.

SPSS does not like the format in the GET DATA below.

*create file with 400 variables to see if SPSS can read a 400 variable CSV file.
new file.
input program.
  vector x (400,f3).
  loop id = 1 to 3.
     loop #p = 1 to 400.
        compute x(#p) = rnd(rv.normal(50,10)).
     end loop.
     end case.
  end loop.
  end file.
end input program.
SAVE TRANSLATE OUTFILE='C:\project\test400.csv'
 /TYPE=CSV
 /ENCODING='Locale'
 /MAP
 /REPLACE
 /FIELDNAMES
 /CELLS=VALUES.
GET DATA  /TYPE=TXT
 /FILE="C:\project\test400.csv"
 /ENCODING='Locale'
 /DELCASE=LINE
 /DELIMITERS=","
 /ARRANGEMENT=DELIMITED
 /FIRSTCASE=2
 /IMPORTCASE=ALL
 /VARIABLES= x1 to x400 (400f2.0).
CACHE.
EXECUTE.


--
Art Kendall
Social Research Consultants

Art Kendall
Social Research Consultants



View this message in context: Get Data format when reading in a 400 variable CSV file
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Get Data format when reading in a 400 variable CSV file

Art Kendall
Rick is right that one needs to have a format specification for each variable.

<file><read text data> works by writing a line per variable.
Art Kendall
Social Research Consultants
On 8/13/2013 4:59 PM, Rick Oliver [via SPSSX Discussion] wrote:
I don't think GET DATA recognizes the "TO" convention. You have to explicitly declare each variable and a format for each variable.

Rick Oliver
Senior Information Developer
IBM Business Analytics (SPSS)
E-mail: [hidden email]




From:        Art Kendall <[hidden email]>
To:        [hidden email],
Date:        08/13/2013 03:43 PM
Subject:        Get Data format when reading in a 400 variable CSV file
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I know I have come across this before but cannot remember how I did it before.

SPSS does not like the format in the GET DATA below.

*create file with 400 variables to see if SPSS can read a 400 variable CSV file.
new file.
input program.
  vector x (400,f3).
  loop id = 1 to 3.
     loop #p = 1 to 400.
        compute x(#p) = rnd(rv.normal(50,10)).
     end loop.
     end case.
  end loop.
  end file.
end input program.
SAVE TRANSLATE OUTFILE='C:\project\test400.csv'
 /TYPE=CSV
 /ENCODING='Locale'
 /MAP
 /REPLACE
 /FIELDNAMES
 /CELLS=VALUES.
GET DATA  /TYPE=TXT
 /FILE="C:\project\test400.csv"
 /ENCODING='Locale'
 /DELCASE=LINE
 /DELIMITERS=","
 /ARRANGEMENT=DELIMITED
 /FIRSTCASE=2
 /IMPORTCASE=ALL
 /VARIABLES= x1 to x400 (400f2.0).
CACHE.
EXECUTE.


--
Art Kendall
Social Research Consultants

Art Kendall
Social Research Consultants



View this message in context: Get Data format when reading in a 400 variable CSV file
Sent from the
SPSSX Discussion mailing list archive at Nabble.com.



To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here.
NAML

Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Get Data format when reading in a 400 variable CSV file

Andy W
In reply to this post by Art Kendall
So data list is not an option? If you have string qualifiers for csv data list is harder, but otherwise if you know the variable formats beforehand you can use the TO convention to specify multiple variables.
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/