BookmarkSubscribeRSS Feed
dereck255
Fluorite | Level 6

Hi,

I have a data set with a variable called Number. Most of the observations have numbers, but those that are missing are "None". When I state that Number is numeric, the SAS Log freaks out saying "Invalid data for Number" each time it encounters "None". When I have Number as a character variable, I can't use any math functions (sum, etc.). How do I tell SAS how to read this variable without the zillions of log errors?

Thanks,

Derek

6 REPLIES 6
Reeza
Super User

What do you want in place of NONE?

dereck255
Fluorite | Level 6

A zero would be fine.

Haikuo
Onyx | Level 15

"I have a data set ....",

What data set? is it SAS table or something else? Show some code and the log you mentioned.

dereck255
Fluorite | Level 6

LOL. It's an excel file. I have no trouble getting the file into SAS - I use an input statement. Can't show code since it has private info.

Haikuo
Onyx | Level 15

try:

input Number ??yournumberformat.;

This will give you . (missing) when 'None',  and the error log will be suppressed.

if you want it to be zero instead,  you can test _infile_ first, then decide whether to input normally or assign zero value.

Good luck,

Haikuo

Howles
Quartz | Level 8

Try something like this.

proc format ;

invalue none_zero 'None' = 0 other = [12.] ;

run ;

data _null_ ;

input val none_zero. ;

put val= ;

cards;

123

None

;

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