I want to import a csv file with 90 variables (columns) and >100K rows. I want to assign row 3 as containing the variable names. The data rows start on row 9. How can I do this with Proc Import?
Thanks in advance...
Gene
Easiest thing to do is delete rows 1 and 2 and delete rows 4-8.
Easiest thing to do is delete rows 1 and 2 and delete rows 4-8.
Did the source of that file provide an adequate contents description to write a data step? Such as column meaning, ranges of values, layout such as currency or dates, maximum length of character variables?
If so, I would write a data step and use the INFILE option Firstobs=9 to skip to the first line of the data wanted.
As a minimum you want to include a Guessingrows=max; statement if using proc import. Otherwise the number of rows examined may result in many mismatches of variable types or truncated values.
Regardless, you want to save the generated data step in the log as you may need to make changes that aren't possible directly with Proc Import and it is often easier to modify some working code (the generated data step) than to start from scratch.
Proc import will treat any series of digits only as a number. Which leads to loss of significant leading zeroes in thing like bank accounts or routing numbers and similar.
If you delete row 2, GETNAMES = YES will work. Then specify DATAROWS = 8 to identify which row to starting read your data from, since you deleted a line.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.