BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

I want to add an option/statement to this step so that only the first 10 obs are imported.

proc import data=map_export datafile="G:\Departments\Research\MAP\1112\Oconee - &admin. - Clean.txt" dbms=dlm replace;

   delimiter='09'x;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

There is no procedure specific option to directly limit the quantity the IMPORT procedure will read in, to my knowledge. You can use the OBS= system option to limit the number of records that SAS will process. Setting OBS=10 will limit the processing to the first 10, then set it back to OBS=MAX so subsequent operations consider the full data.

 

options obs=10;
proc import
  datafile="G:\Departments\Research\MAP\1112\Oconee - &admin. - Clean.txt"
  out=map_export
  dbms=dlm
  replace;
  delimiter='09'x;
run;

options obs=max;

 

Since this is a text file, you should also consider using the DATA step with an INFILE statement to read the data. It requires more knowledge of the data fields as you read them, but that approach provides much more control over how much data is read in. See this topic for more guidance and troubleshooting.

 

(Editor's note: modified this reply for clarification and more detail on this popular topic.)

View solution in original post

1 REPLY 1
FriedEgg
SAS Employee

There is no procedure specific option to directly limit the quantity the IMPORT procedure will read in, to my knowledge. You can use the OBS= system option to limit the number of records that SAS will process. Setting OBS=10 will limit the processing to the first 10, then set it back to OBS=MAX so subsequent operations consider the full data.

 

options obs=10;
proc import
  datafile="G:\Departments\Research\MAP\1112\Oconee - &admin. - Clean.txt"
  out=map_export
  dbms=dlm
  replace;
  delimiter='09'x;
run;

options obs=max;

 

Since this is a text file, you should also consider using the DATA step with an INFILE statement to read the data. It requires more knowledge of the data fields as you read them, but that approach provides much more control over how much data is read in. See this topic for more guidance and troubleshooting.

 

(Editor's note: modified this reply for clarification and more detail on this popular topic.)

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 31425 views
  • 0 likes
  • 2 in conversation