dearest list-
I am working on a project which requires import of data into SPSS from a file created by a Web Application. The application itself already is setup to write out flat files (.xls,.tab,.csv). At present, the data can be imported into SPSS just fine, but then the SPSS Analyst has to create the Data definitions and any Variable types they need. I am hoping someone on this list has some experience with this, and could possibly help me out with mapping our data types to their functional analogs in SPSS so they show up in the 'Variable View' tab with the correct restrictions. my variable types: text : alphanumeric string integer : max/min float : max/min enum : set with possible values and indices bool : 1:0 i have seen some syntax that indicates i can use 'DATA LIST' to do some type definition, but i don't have the exact syntax for my variable types. also, i would prefer not to have to use a fixed-width definition (although i can if i *have* to) any suggestions? TIA, DanO |
This is a very, VERY old answer, but I see I started a draft.
At 12:12 AM 8/19/2006, Dan Olsen wrote: >I am working on a project which requires import of data into SPSS from >a file created by a Web Application. The application itself already is >setup to write out flat files (.xls,.tab,.csv). At present, the data >can be imported into SPSS just fine, but then the SPSS Analyst has to >create the Data definitions and any Variable types they need. [I want >to] map our data types to their functional analogs in SPSS so they >show up in the 'Variable View' tab with the correct restrictions. > >my variable types: >text : alphanumeric string >integer : max/min >float : max/min >enum : set with possible values and indices >bool : 1:0 > >i have seen some syntax that indicates i can use 'DATA LIST' to do >some type definition, but i don't have the exact syntax for my >variable types. also, i would prefer not to have to use a fixed-width >definition. Did you get this resolved, or give up, or is it still open? DATA LIST is not at all restricted to fixed-width *input*. SPSS string variables are fixed-width; that's simply a design limitation. The standard practice is to declare the strings to cover the greatest width you'll need, and live with the wasted space. >At present, the data can be imported into SPSS just fine, but then the >SPSS Analyst has to create the Data definitions and any Variable types >they need. To assign variable names, either you use field names you can read from your data; or, somebody puts them in by hand; or, you generate arbitrary ones like VAR001, VAR002, etc. (The last is actually a fairly good choice if there are many fields, but I'd recommend a prefix that says something about the data source or project, rather than "VAR".) >my variable types: >text : alphanumeric string >integer : max/min >float : max/min >enum : set with possible values and indices >bool : 1:0 Now, SPSS has only two datatypes: fixed-length alphanumeric string, and numeric. (Numeric are stored as 64-bit floating.) All your numeric types (I'm including 'enum' as numeric, though it can be mapped into string variables as well) can be represented nicely as SPSS numeric, often with wasted space but what the heck. What SPSS *can't* do is enforce the value constraints; or even check them, during input. If the variable definitions, including types and constraints, are in a form that's reasonably easy to parse, and if there are a lot of variables, I'd probably write SPSS code that parsed the definitions and generated SPSS code to apply appropriate formats, variable and value labels, and syntax to check the constraints. If you have SPSS 14+, and know or want to learn Python, the parsing and code-generating may be easier in Python. And the constraints can be made user-defined variable attributes, so Python can look them up and generate the code to check them, directly from the SPSS file. |
Free forum by Nabble | Edit this page |