BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

I attached a notepad file containing first 5 rows from a csv file. I used the following code. It worked. But I am not understanding why I have use firstrow=6 rather than firstrow=5 when the data starts in the 5 row.

 

data dv;
infile "C:\Users\tt\Desktop\three.csv"
delimiter=',' firstobs=6 missover dsd;
format Screening_no DescOfDev Day DateDev DateIdentified Classification Category Outcome ReportedToRA ReportedToIRB ActionRequired $200.;
input Deviation_no Screening_no Subject DescOfDev Day DateDev DateIdentified Classification Category Outcome ReportedToRA ReportedToIRB ActionRequired;
run;

4 REPLIES 4
knveraraju91
Barite | Level 11

Dear,

 

I attached a notepad file containing first 5 rows from a csv file. I used the following code. It worked. But I am not understanding why I have use firstobs=6 rather than firstobs=5 when the data starts in the 5 row. I am getting variable names in first row when I used firstrow=5. Please. Thanks 

data one;
infile "C:\User\tt\Desk\thre.csv"
delimiter=',' firstobs=6 missover dsd;
format Screening_no DescOfDev Day DateDev DateIdentified Classification Category Outcome ReportedToRA ReportedToIRB ActionRequired $200.;
input Deviation_no Screening_no Subject DescOfDev Day DateDev DateIdentified Classification Category Outcome ReportedToRA ReportedToIRB ActionRequired;
run;

PeterClemmensen
Tourmaline | Level 20

According to the preview of your data file, it does contain six rows? 🙂

ballardw
Super User

It looks like you may have extra linefeeds in your data.

 

For instance:

Deviation #,"Screening 
Number",Subject ID                     Number,Description 

looks like the field containng Screening Number has a line feed and Number" starts on a different obs when SAS reads the file.

 

If the first line of actual data is the one that starts this way:

0,O-0000,1000

Then that is the 6th line of the file.

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Row 5 doesn't contain data from what I can see, it contains variables names.  As you specify variable names on your input statement:

input Deviation_no Screening_no Subject DescOfDev Day DateDev DateIdentified Classification Category Outcome ReportedToRA ReportedToIRB ActionRequired;

 

You don't need to read Row 5, just the data, which starts at row 6

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 921 views
  • 3 likes
  • 4 in conversation