DATA Step, Macro, Functions and more

Informats

Reply
Occasional Contributor
Posts: 19

Informats

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!)

Super User
Posts: 10,280

Re: Informats

Posted in reply to GAUTAMDVN

Please show your code and the log from it, if you get errors.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 23,778

Re: Informats

Posted in reply to GAUTAMDVN

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!)


 

Occasional Contributor
Posts: 19

Re: Informats

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.
Super User
Posts: 23,778

Re: Informats

Posted in reply to GAUTAMDVN

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.

 

Occasional Contributor
Posts: 19

Re: Informats

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.
Super User
Posts: 23,778

Re: Informats

Posted in reply to GAUTAMDVN

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.

 

Super User
Posts: 23,778

Re: Informats

Or compare your code to the one used in your other question. That one seems to reference the file correctly to read it in, use the same approach here.
Super User
Posts: 10,280

Re: Informats

Posted in reply to GAUTAMDVN

@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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Regular Contributor
Posts: 213

Re: Informats

Posted in reply to GAUTAMDVN

@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.

Super User
Super User
Posts: 8,127

Re: Informats

Posted in reply to GAUTAMDVN

Why do you have FILE statement without any PUT statements?

Super User
Posts: 10,280

Re: Informats

Posted in reply to GAUTAMDVN

@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.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 8,127

Re: Informats

Posted in reply to GAUTAMDVN

@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.

Ask a Question
Discussion stats
  • 12 replies
  • 144 views
  • 0 likes
  • 5 in conversation