BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11

Hello team,

there is an option when we want to import data into SAS, it is called missover. I read times and times.

This option states if the length of read variable is shorter than the length of variable in SAS, then leave the variable blank/ or missing.

 

So, we don't have any control over the length of what we insert into a variable/ field. A family name can be 5 character like robert or it might be smithtra 8 characters, we want both read to SAS. 

 

Can someone resolve this for me?

 

Regards.

Blue is the color of sky!!

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@GN0001 wrote:

 

there is an option when we want to import data into SAS, it is called missover. I read times and times.

This option states if the length of read variable is shorter than the length of variable in SAS, then leave the variable blank/ or missing.


It doesn't say that. Here's what it says

 

MISSOVER

prevents an INPUT statement from reading a new input data record if it does not find values in the current input line for all the variables in the statement. When an INPUT statement reaches the end of the current input data record, variables without any values assigned are set to missing.

 

So, MISSOVER looks at the input record from a file or CARDS, and if it does not find enough for all the variables it is expecting, it sets the remaining variables to missing. Length of a variable is not relevant here.

 

Example: Here SAS is expecting to find 5 values. If a record has less than 5 values, then the rest are set to missing.

 

data a;
    infile cards missover;
    input x1 x2 x3 x4 x5;
    cards;
8 12 10 3
7
8 9 10 11 12
8 9 10 11 12 13
;

 

I leave it as a homework assignment for you to see what happens without MISSOVER and compare what happens with MISSOVER.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@GN0001 wrote:

 

there is an option when we want to import data into SAS, it is called missover. I read times and times.

This option states if the length of read variable is shorter than the length of variable in SAS, then leave the variable blank/ or missing.


It doesn't say that. Here's what it says

 

MISSOVER

prevents an INPUT statement from reading a new input data record if it does not find values in the current input line for all the variables in the statement. When an INPUT statement reaches the end of the current input data record, variables without any values assigned are set to missing.

 

So, MISSOVER looks at the input record from a file or CARDS, and if it does not find enough for all the variables it is expecting, it sets the remaining variables to missing. Length of a variable is not relevant here.

 

Example: Here SAS is expecting to find 5 values. If a record has less than 5 values, then the rest are set to missing.

 

data a;
    infile cards missover;
    input x1 x2 x3 x4 x5;
    cards;
8 12 10 3
7
8 9 10 11 12
8 9 10 11 12 13
;

 

I leave it as a homework assignment for you to see what happens without MISSOVER and compare what happens with MISSOVER.

--
Paige Miller
GN0001
Barite | Level 11

Thanks, it was a great practice!!!

Blue Blue
Tom
Super User Tom
Super User

You will rarely ever want to the the MISSOVER option.

Use the TRUNCOVER option instead.

 

The difference is when you try to read using a fixed length format and there are not enough characters on the line.

With missover the characters that are there are ignored and the value is set to missing.

With truncover the characters that are there are read.

 

So you have a variable length text file with a DATE value that can be up to 10 character wide.

12/23/2022
1/4/2021
01/20/2022

And you want to read it with this input statement.

   input date mmddyy10. ;

If you use MISSOVER option that middle line will be missing because there are only 8 characters and not 10.

But if you use TRUNCOVER option instead then the date will be properly read.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 3 replies
  • 1089 views
  • 2 likes
  • 3 in conversation