Help using Base SAS procedures

Help import a csv file into sas and read all the datas

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Help import a csv file into sas and read all the datas

Hey everyone!

 

I am trying to import a dataset downloaded from California Health and Human Services website, in csv format. The file has about 893 rows and 5 columns. I want to import the file and build a dataset, so that I can do further research. But the log keeps showing that my sas cannot read the file.("0 records were read from the infile"), and I don't know how to fix that. so Here is the i am using:

 

DATA ETHINICITY;
INFILE 'C:\Users\Administrator\Downloads\Violent_Crime_Rate_California_2006-2010.csv'

lrecl=32767 missover pad;
RUN;

 

Here is the log:

The infile 'C:\Users\Administrator\Downloads\Violent_Crime_Rate_California_2006-2010.csv'
is:
Filename=C:\Users\Administrator\Downloads\Violent_Crime_Rate_California_2006-2010.csv,
RECFM=V,LRECL=32767,File Size (bytes)=1319201,
Last Modified=23Apr2017:22:22:13,
Create Time=23Apr2017:22:22:12

NOTE: 0 records were read from the infile
'C:\Users\Administrator\Downloads\Violent_Crime_Rate_California_2006-2010.csv'.
NOTE: The data set WORK.ETHINICITY has 1 observations and 0 variables.

Attachment

Accepted Solutions
Solution
‎04-24-2017 12:57 PM
PROC Star
Posts: 7,364

Re: Help import a csv file into sas and read all the datas

Also, the file ;you attached isn't the same on you specified on the infile statement. Assuming the file you attached is the correct one, and that it's in the same location as the other file you specified, the following should work:

 

DATA ETHINICITY;
  INFILE 'C:\Users\Administrator\Downloads\Physicians_and_Surgeons_by_Race_Ethnicity_and_Practice_Location.csv'
    dlm=',' lrecl=32767 missover firstobs=2 pad;
  informat Primary_Practice_County $14.;
  informat Race_Ethnicity $36.;
  input Month $ Year Primary_Practice_County Race_Ethnicity Count_of_Licensees;
RUN;

Art, CEO, AnalystFinder.com

View solution in original post


All Replies
PROC Star
Posts: 7,364

Re: Help import a csv file into sas and read all the datas

You don't have an input statement specifying the variables to input.

 

I didn't look at the file but, if it has a header row (i.e., a row with the variable names), you might find it easier to use proc import.

 

Art, CEO, AnalystFinder.com

 

Solution
‎04-24-2017 12:57 PM
PROC Star
Posts: 7,364

Re: Help import a csv file into sas and read all the datas

Also, the file ;you attached isn't the same on you specified on the infile statement. Assuming the file you attached is the correct one, and that it's in the same location as the other file you specified, the following should work:

 

DATA ETHINICITY;
  INFILE 'C:\Users\Administrator\Downloads\Physicians_and_Surgeons_by_Race_Ethnicity_and_Practice_Location.csv'
    dlm=',' lrecl=32767 missover firstobs=2 pad;
  informat Primary_Practice_County $14.;
  informat Race_Ethnicity $36.;
  input Month $ Year Primary_Practice_County Race_Ethnicity Count_of_Licensees;
RUN;

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 8

Re: Help import a csv file into sas and read all the datas

Thank you so much! I do attach a wrong file, and I should have checked it carefully, but it perfectly solved my problem!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 184 views
  • 1 like
  • 2 in conversation