|
Size: 865
Comment:
|
← Revision 4 as of 2024-11-17 23:37:45 ⇥
Size: 930
Comment: Rewrite
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 2: | Line 2: |
A utility procedure for generating a data step that imports a data file. |
|
| Line 11: | Line 13: |
| To import a CSV file, try: |
|
| Line 19: | Line 23: |
| To import a Stata file, try: {{{ proc import datafile=FILEREF out=LIBREF.TABLE; run; }}} |
|
| Line 23: | Line 35: |
| Generally the '''`GETNAMES`''' statement should always be used. See above. | The '''`GETNAMES`''' statement is almost always useful for text data. |
| Line 29: | Line 41: |
| The `IMPORT` procedure guesses the format of each variable based on peaking ahead and observing values. This can lead to issues when numeric and character values are mixed. The best solution is usually the '''`GUESSINGROWS`''' statement. | The `IMPORT` procedure guesses the format of each variable based on peaking ahead some number of cases (controlled by the '''`GUESSINGROWS`''' statement). The best solution is usually setting this parameter to `MAX`. |
| Line 31: | Line 43: |
| {{{ proc import datafile=data_v2 out=work.raw dbms=csv; guessingrows=max; run; }}} `GUESSINGROWS` can be set to any positive integer or `MAX`. If this also fails, consider copying the syntax generated by the `IMPORT` procedure and manually correcting it. |
If SAS consistently fails to guess the import format of data, consider copying the syntax generated by the `IMPORT` procedure and manually correcting it. |
SAS Import
A utility procedure for generating a data step that imports a data file.
Usage
To import a CSV file, try:
proc import datafile=FILEREF
out=LIBREF.TABLE
dbms=csv;
getnames=yes;
run;To import a Stata file, try:
proc import datafile=FILEREF
out=LIBREF.TABLE;
run;
GetNames Statement
The GETNAMES statement is almost always useful for text data.
GuessingRows Statement
The IMPORT procedure guesses the format of each variable based on peaking ahead some number of cases (controlled by the GUESSINGROWS statement). The best solution is usually setting this parameter to MAX.
If SAS consistently fails to guess the import format of data, consider copying the syntax generated by the IMPORT procedure and manually correcting it.
