BookmarkSubscribeRSS Feed
OceanDream
Fluorite | Level 6

I'm trying to import a large CSV file into SAS. When I imported, I found that some variables were not imported properly. For example, there is a variable, which is a number. The range is [0, 1], i.e., the value is 0.0004. When I imported, it becomes a dummy variable, either 0 or 1. What can I do to get the original value??? Thanks in advance!

 

PROC IMPORT OUT= WANTED
DATAFILE= "HAVE.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;

4 REPLIES 4
data_null__
Jade | Level 19

@OceanDream wrote:

I'm trying to import a large CSV file into SAS. When I imported, I found that some variables were not imported properly. For example, there is a variable, which is a number. The range is [0, 1], i.e., the value is 0.0004. When I imported, it becomes a dummy variable, either 0 or 1. What can I do to get the original value??? Thanks in advance!


Show the data.  Show the code.

ballardw
Super User

Look at several things. First is the CSV file and preferrably not using a spreadsheet program as most of those will make lots of assumptions about the data. Verify that the data is indeed 0.0004 or whatever.

 

Second is to add and supply a large value for guessingrows. By default SAS only examines a few rows to "guess" what the contents of a column may be. The first rows may have not been sufficient to note your decimals.

PROC IMPORT OUT= WANTED
DATAFILE= "HAVE.csv"
DBMS=CSV REPLACE;

Guessingrows = 32000;
GETNAMES=YES;
DATAROW=2;
RUN;

 

Third, look at the datastep code generated by proc import. It will tell you exactly what informat and format were assigned. You can copy the code and paste it into the editor and modify to make any desired changes such as changing informat or format, add labels and possibly get more useful variable names.

OceanDream
Fluorite | Level 6

ballardw, thank you very much! After I added "Guessingrows = 32000;", it works very well. you are right that SAS only uses a few rows to guess. And since my dataset has a lot of missing values, SAS just assumed it's a dummy variable. 

Reeza
Super User

@OceanDream Please mark the question answered if you have a solution. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1424 views
  • 1 like
  • 4 in conversation