## missing values/ counting line of data

Solved
Occasional Contributor
Posts: 8

# missing values/ counting line of data

Hi I am new to SAS and encountered the following problem with missing values.

From the example below i didn't understand how you can count the line of data to allocate numerica data for the values. See below

 Id Cholesterol Age Gender Syst1olic Diastolic Height Weight SES 1 0 53 M 110 65 64.3147.45 2 2 0 48 F 120 72 69.2167.35 1 3 1 53 F 120 90 70.8 4 4 1 53 120 80 72.5229.21 4 5 0 45 m 118 74 66.1134.96 3

@1 ID  @3 cholest @5 age @8 gender @10 s ystolic @14  diastolic @17  height @22 weight  @29 SES

How to you count the line of data to get  ID=3 , cholest=5,  age=8, gender=8 and etc.

Accepted Solutions
Solution
‎07-27-2013 10:28 AM
SAS Super FREQ
Posts: 9,370

## Re: missing values/ counting line of data

Hi:

I believe that you would be better served by asking your professor or teaching assistant to explain what the "counting along a line of data means". However, in the meantime, consider if you had a piece of graph paper and that every character and space took up one square of the graph paper. This is how SAS reads your "raw data" file, as though every character is in 1 square in a piece of hypothetical graph paper.

consider the following data:

1 0 42 m 110 65 64.3 147.45 2

2 0 53 f 130 72 69.2 167.35 1

And, notice how everything "lines up" (if you look at it in Notepad, displayed with a "fixed pitch" font like Courier). Every character takes 1 "position" or character position or column in the text file. Now, lets put a "counter" or "ruler" above this data:

.........1.........2........2

12345678901234567890123456789 <-- "invisible ruler" where every character is a "column"

-----------------------------

1 0 42 m 110 65 64.3 147.45 2

2 0 53 f 130 72 69.2 167.35 1

The "ruler" starts above the line of dashes and your data is below. ID starts in column 1; the m or f is in column 8; the systolic value starts in column 10 and the diastolic value starts in column 14. You can see how the 110 lines up underneath columns 10, 11 and 12 and how 65 lines up underneath columns 14 and 15. If you place your cursor in position 1 (immediately under the 1 on the ruler), and then move the right arrow cursor key, you can "count" out loud every time the cursor moves one position to the right. In the attached screen shots, I show the "fat" cursor positioned on character 1, on character 8 and on character 14.

When you are reading data with an INPUT statement, if the data are in fixed columns (as your data is in fixed columns), then you use @ pointer control to point to the correct column or "square in the graph paper" to tell SAS where the beginning column is for reading.

Your book gives you the mostly correct INPUT statement for the data, as laid out. It seems to me that the book explains that you will still have problems with the program as written because of the treatment of missing values. So I would expect that when you turn the page, your book will have an explanation of an option that will probably help you read the data as you need to do for your assignment.

It also seems to me that your book is stepping you through the process of writing your program using a trial and error basis. But the whole program in your book is built on the premise that you understand how to "count" the characters on each dataline to understand the correct @ pointer to use in the INPUT statement.

Hope this explanation helps you get a bit more understanding what is meant by "counting" across the data line.

cynthia

All Replies
Occasional Contributor
Posts: 8

## Re: missing values/ counting line of data

Sorry if the question wasn't clear.

I attached a document with the question. Basically I couldn't workout the data line count, how do you count, vertical or horizontal.

Super Contributor
Posts: 312

## Re: missing values/ counting line of data

So I gather you are reading the above in from a text file?

Can you go into the text file using notepad and copy the text into a post?

Is this what you are trying to have returned in your output? ID=3 , cholest=5,  age=8, gender=8.

I am a little lost on what you want.

Solution
‎07-27-2013 10:28 AM
SAS Super FREQ
Posts: 9,370

## Re: missing values/ counting line of data

Hi:

I believe that you would be better served by asking your professor or teaching assistant to explain what the "counting along a line of data means". However, in the meantime, consider if you had a piece of graph paper and that every character and space took up one square of the graph paper. This is how SAS reads your "raw data" file, as though every character is in 1 square in a piece of hypothetical graph paper.

consider the following data:

1 0 42 m 110 65 64.3 147.45 2

2 0 53 f 130 72 69.2 167.35 1

And, notice how everything "lines up" (if you look at it in Notepad, displayed with a "fixed pitch" font like Courier). Every character takes 1 "position" or character position or column in the text file. Now, lets put a "counter" or "ruler" above this data:

.........1.........2........2

12345678901234567890123456789 <-- "invisible ruler" where every character is a "column"

-----------------------------

1 0 42 m 110 65 64.3 147.45 2

2 0 53 f 130 72 69.2 167.35 1

The "ruler" starts above the line of dashes and your data is below. ID starts in column 1; the m or f is in column 8; the systolic value starts in column 10 and the diastolic value starts in column 14. You can see how the 110 lines up underneath columns 10, 11 and 12 and how 65 lines up underneath columns 14 and 15. If you place your cursor in position 1 (immediately under the 1 on the ruler), and then move the right arrow cursor key, you can "count" out loud every time the cursor moves one position to the right. In the attached screen shots, I show the "fat" cursor positioned on character 1, on character 8 and on character 14.

When you are reading data with an INPUT statement, if the data are in fixed columns (as your data is in fixed columns), then you use @ pointer control to point to the correct column or "square in the graph paper" to tell SAS where the beginning column is for reading.

Your book gives you the mostly correct INPUT statement for the data, as laid out. It seems to me that the book explains that you will still have problems with the program as written because of the treatment of missing values. So I would expect that when you turn the page, your book will have an explanation of an option that will probably help you read the data as you need to do for your assignment.

It also seems to me that your book is stepping you through the process of writing your program using a trial and error basis. But the whole program in your book is built on the premise that you understand how to "count" the characters on each dataline to understand the correct @ pointer to use in the INPUT statement.

Hope this explanation helps you get a bit more understanding what is meant by "counting" across the data line.

cynthia

Occasional Contributor
Posts: 8

Thanks Cynthia

Thank you

Eddie

New Contributor
Posts: 4

## Re: missing values/ counting line of data

Did you try using the MISSOVER option?

http://www2.sas.com/proceedings/sugi26/p009-26.pdf

🔒 This topic is solved and locked.