In SAS 9.1 and SAS® 9.2, the GUESSINGROWS= value can range from 1 to 32767. Beginning in SAS® 9.1, a new statement (GUESSINGROWS=) is available in PROC IMPORT that enables you to tell SAS how many rows you want it to scan in order to determine variable attributes. In this situation, how do you prevent the Invalid Data message in the SAS log?īy default, SAS scans the first 20 rows to determine variable attributes (type and length) when it reads a comma-, tab-, or otherwise-delimited file. NOTE: The data set WORK.CLASS has 38 observations and 5 variables. Height= 62.5 Weight= 112.5 _ERROR_= 1 _N_= 27 NOTE: 38 records were read from the infile 'c: \temp \classdata.csv'. NOTE: Invalid data for Age in line 28 9- 10. In this scenario, I use PROC IMPORT to read a comma-delimited file that has variable names on row 1 and data starting on row 2, as shown below: Scenario 1: Variable names on row 1, values beginning row 2 The following sections explain four different scenarios for using PROC IMPORT to read text files with delimited values. Peter Styliadis, a trainer with SAS, shows how to use PROC IMPORT to read CSV data in this tutorial. Note: PROC IMPORT is available only for use in the Microsoft Windows, UNIX, or Linux operating environments. However, depending on the circumstances, you might have to add the GUESSINGROWS= statement to PROC IMPORT or you might need to pre-process the delimited file before you use PROC IMPORT. You can still use PROC IMPORT to read the comma-, tab-, or otherwise-delimited files. So how do you read files that do not follow those restrictions? Unfortunately, most delimited files are not created with those restrictions in mind. It's easy in that variable names are on row 1, the data starts on row 2, and the first 20 rows are a good sample of your data. Reading an external file that contains delimiters (commas, tabs, or other characters such as a pipe character or an exclamation point) is easy when you use the IMPORT procedure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |