BookmarkSubscribeRSS Feed
pjy1006
Calcite | Level 5

I used proc import to import data from csv file.  For some long numeric columns ( for ex, 456789123), csv shows scientific notation(for ex, 4.20E+8).  So when SAS reads in CSV, it is converted to 400000000 (instead of the original, correct number = 456789123).  I want to add a data quality checking step to alert myself that CSV actually is a scientific notation.  How can I have SAS show that column as 4.20E+8 (that way, I will be able to pop up an error message for myself)?

 

proc import datafile = "inputfile.csv"
out = outds
dbms = csv replace;
getnames = YES;

run;

2 REPLIES 2
Kurt_Bremser
Super User

Whenever importing data gets complicated (read: ALWAYS), do not use proc import, but write your own data step. In that, you can read this column into a temporary character variable, check for the notation, and then either convert to the final numeric variable (if no scientific notation) or set a flag.

hashman
Ammonite | Level 13

@Kurt_Bremser:

"do not use proc import, but write your own data step"

 

You've said a mouthful!

 

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 2041 views
  • 1 like
  • 3 in conversation