BookmarkSubscribeRSS Feed
GreggB
Pyrite | Level 9
*** GET MOST RECENT ROSTER ***;
proc import datafile="G:\Departments\Preliminary_Score_Ro - 26MAY21.csv"
out=eoc dbms=dlm replace;
delimiter=',';
guessingrows=all;
run; 
proc print data=eoc (obs=5);
run;

OUTPUT:

Obs Data_extract_produced_by_28BCB4 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 VAR16 VAR17 VAR18 VAR19 VAR20 VAR21 VAR22 VAR23 VAR24 VAR25 
1 Admin: EOCEP Spring 2021 | District: OXXXXX | Schools: xxx Academy, xxx Adult Education, xxx High, xxx Middle, xxx High, xxx Middle, xxx Middle, xxx High                                                 
2                                                   
3 Time Posted Teacher SIS Code Student Last Name Student First Name MI Subject Scale Score Letter Grade Test Indicator Tested School Name Tested School Code Reported School Code SC Virtual School Program Bubbled Last Name Bubbled First Name Bubbled MI State ID Student ID PS Grade Race/Ethnicity Gender Birthdate Course Number Course Name 
4 05/13/2021 03:31:54 S C xxxxxx 302501CW-0007 xxxxxxx ALEXIS   English 2 xx F ONLINE xxx-Oak High 3701xxx 3701008         xxxxxxxxxx 19174 09 H M 10/30/2xxx 3025 English 2 
5 05/13/2021 03:31:54 H J Mxxxx 302501CW-0008 xxxxSON CORBIN L English 2 xx F ONLINE xxx-Oak High 3701xxx 3701008         xxxxxxxxxx 10994 09 W M 10/29/2xxx 3025 English 2 

WHAT I NEED:

1. Row 1 deleted

2. Row 2 deleted

3.. Row 3 are the headers

4. Row 4 should be the first data row

6 REPLIES 6
Reeza
Super User
Take the code from the log that reads in the data, the data step not the PROC IMPORT.
Add in the FIRSTOBS=4 to the INFILE statement and you should get what you need.
GreggB
Pyrite | Level 9

That reads the data in nicely. I was hoping to be able to get the values in row 1 and assign them as variable names (without have to use the RENAME option in the data step.

 

Obs Data_extract_produced_by_28BCB4 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 VAR9 VAR10 VAR11 VAR12 VAR13 VAR14 VAR15 VAR16 VAR17 VAR18 VAR19 VAR20 VAR21 VAR22 VAR23 VAR24 VAR25 
1 Time Posted Teacher SIS Code Student Last Name Student First Name MI Subject Scale Score Letter Grade Test Indicator Tested School Name Tested School Code Reported School Code SC Virtual School Program Bubbled Last Name Bubbled First Name Bubbled MI State ID Student ID PS Grade Race/Ethnicity Gender Birthdate Course Number Course Name 

Reeza
Super User
You can try adding the datarow=4 & GETNAMES=YES to the PROC IMPORT and see if that works as well?

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p08ss3c3xtt2qzn1fsma45gyz333.htm

Tom
Super User Tom
Super User

Is the structure of the CSV file changing day to day?  If not then skip the PROC IMPORT and just read the file with your own data step.  That way not only can you control which line to start reading the data but you will full control over how the variables are defined.  So this weeks roster won't have a different length (or worse type) for some of the variables.

 

Or make a copy of the file without those extra lines and run PROC IMPORT on that.

filename copy temp;
data _null_;
  infile proc import datafile="G:\Departments\Preliminary_Score_Ro - 26MAY21.csv"
     firstobs=4
  ;
  file copy;
  input;
  put _infile_;
run;
proc import datafile=copy dbms=csv out=eoc replace;
  guessingrows=all;
run; 
GreggB
Pyrite | Level 9
filename copy temp;
data _null_;
infile proc import datafile="G:\Departments\Research\test scores\EndOfCourse\2021\Spring\Preliminary_Score_Ro - 26MAY21.csv"
firstobs=4
;
file copy;
input;
put _infile_;
run;
proc import datafile=copy dbms=csv out=eoc replace;
guessingrows=all;
run;

LOG

96   filename copy temp;
97   data _null_;
98     infile proc import datafile="G:\Departments\Research\test
                   ------
                   23
ERROR 23-2: Invalid option name IMPORT.

98 !   infile proc import datafile="G:\Departments\Research\test
                          --------
                          23
98 ! scores\Preliminary_Score_Ro - 26MAY21.csv"
ERROR 23-2: Invalid option name DATAFILE.

99        firstobs=4
100    ;
101    file copy;
102    input;
103    put _infile_;
104  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


105  proc import datafile=copy dbms=csv out=eoc replace;
106    guessingrows=all;
107  run;

WARNING: Physical file does not exist,
C:\Users\XXXXX\AppData\Local\Temp\SAS Temporary
Files\_TD1356_5CG9231V8L_\#LN00077.
ERROR: Import unsuccessful.  See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
Tom
Super User Tom
Super User
Remove the "proc import datafile=" gibberish that got included when copying the filename from your original code.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 3919 views
  • 3 likes
  • 3 in conversation