- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, it was a great practice!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.