In the raw Crime stats data file, change the delimiter from comma to space and then import the file into SAS (be careful about embedded space in the city name!)
Please show your code and the log from it, if you get errors.
What’s your question? That reads like a homework or test question - so show your work so far.
@GAUTAMDVN wrote:
In the raw Crime stats data file, change the delimiter from comma to space and then import the file into SAS (be careful about embedded space in the city name!)
Below is the code of mine:
DATA _NULL_ ;
INFILE CRIME DSD;
INPUT City : $18.
Population
Crime_index
Total_crime_index
MANM
Forcible_rape
Robbery
Aggravated_assault
Burglary
Larceny_theft
Motor_vehicle_theft
Arson ;
FILE 'LEARN.CRIME_STATS.TXT' ;
RUN ;
and below is the error I'm getting
Your infile statement is incorrect.
It should be of the form:
infile 'path to file including extension' dlm=' ' truncover;
Your file reference comes after so try and move it up and see if that works.
@GAUTAMDVN wrote:
Below is the code of mine:
DATA _NULL_ ; INFILE CRIME DSD; INPUT City : $18. Population Crime_index Total_crime_index MANM Forcible_rape Robbery Aggravated_assault Burglary Larceny_theft Motor_vehicle_theft Arson ; FILE 'LEARN.CRIME_STATS.TXT' ; RUN ;
and below is the error I'm getting
ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/LEARN.CRIME_STATS.TXT.
Hi, thanks for helping but no luck SAS log window showing the same error.
Post your code and log again then.
@GAUTAMDVN wrote:
Hi, thanks for helping but no luck SAS log window showing the same error.
ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/LEARN.CRIME_STATS.TXT.
@GAUTAMDVN wrote:
Hi, thanks for helping but no luck SAS log window showing the same error.
ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/LEARN.CRIME_STATS.TXT.
When you do not specify an absolute path, SAS will look for the file in the current working directory. You have to specify a fully qualified path name starting at root.
@GAUTAMDVN wrote:Hi, thanks for helping but no luck SAS log window showing the same error.
ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/LEARN.CRIME_STATS.TXT.
Then the path you provided is still not correct. Without seeing the code you submitted, i can just guess what went wrong.
Why do you have FILE statement without any PUT statements?
@GAUTAMDVN wrote:
Below is the code of mine:
DATA _NULL_ ; INFILE CRIME DSD; INPUT City : $18. Population Crime_index Total_crime_index MANM Forcible_rape Robbery Aggravated_assault Burglary Larceny_theft Motor_vehicle_theft Arson ; FILE 'LEARN.CRIME_STATS.TXT' ; RUN ;
and below is the error I'm getting
ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/LEARN.CRIME_STATS.TXT.
This whole step serves no purpose. It reads some data from an external file, but does not out that anywhere.
Since you have no put statement to write data to the external file named in the file statement, that statement is useless.
If you want to read data from an external file into a dataset, you have to name that dataset in the data statement.
So you should test this:
data want;
infile crime dsd;
input
City : $18.
Population
Crime_index
Total_crime_index
MANM
Forcible_rape
Robbery
Aggravated_assault
Burglary
Larceny_theft
Motor_vehicle_theft
Arson
;
run;
and post the log from that.
@GAUTAMDVN wrote:
In the raw Crime stats data file, change the delimiter from comma to space and then import the file into SAS (be careful about embedded space in the city name!)
Sounds like they want a two step process.
1) change the delimiter from comma to space
2) import the file into SAS
I assume the mean to use the output of the first task as the input to the second.
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!
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.