Help using Base SAS procedures

Proc import not able to capture all data.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Proc import not able to capture all data.

Hello Everyone!

 

I want to capture around 1.5 lakhs of records in CSV files into SAS environment. The sheet contain three character variables (pat_name, product and dose)

While importing, I am missing some text available in the variable product.

It means if the CSV file contain product name as "Atorvastatin hydrochloride", then the imported SAS file display as only part of text i.e."Atorvastatin hydro"

 

proc import datafile="/abc/bcod/sat.csv"
out=qcx
dbms=csv
replace;
getnames=yes;
run;


Accepted Solutions
Solution
‎11-28-2017 05:32 AM
Super User
Posts: 13,542

Re: Proc import not able to capture all data.

Proc import for delimited files has an option GUESSINGROWS that tells the procedure how many lines to examine before assigning lengths and types to variables. Without the option SAS only examines the first 20 rows or so by default depending on system options.

Use a largish value like guessingrows=32000 to have a better chance.

 

I recommend this for any Proc Import call where available. Note that large values may increase processing time but the tradeoff may be worth the reduced recoding effort.

View solution in original post


All Replies
Super User
Posts: 10,257

Re: Proc import not able to capture all data.

Look at the log of your import step. You will find the data step code that was created by proc import. Copy that, and adapt the length of the variable in question to your needs.

To remove the line numbers, hold down the alt key while selecting the text to be copied.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Solution
‎11-28-2017 05:32 AM
Super User
Posts: 13,542

Re: Proc import not able to capture all data.

Proc import for delimited files has an option GUESSINGROWS that tells the procedure how many lines to examine before assigning lengths and types to variables. Without the option SAS only examines the first 20 rows or so by default depending on system options.

Use a largish value like guessingrows=32000 to have a better chance.

 

I recommend this for any Proc Import call where available. Note that large values may increase processing time but the tradeoff may be worth the reduced recoding effort.

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 206 views
  • 2 likes
  • 3 in conversation