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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 34007 views
  • 0 likes
  • 2 in conversation