data news;
input Score 13. Last_Name : $10. (Ans1-Ans3)($1.);
datalines;
12345678 raje Abc
12345678901234 raje Abc
65 sMITH CCd
95 scerbo DeD
;
proc print;run;
1obs: score=12345678 raje,so missing and last_name=abc ---->fine
but ans1 and ans2 and ans3 should read from next row first values automatically , right?
but why this is not happening??
DATALINES are automatically padded (with blanks) to 80 characters. Since you do not use the colon modifier for the $1. informat, blanks are read from zhe padding of the first line into ans1 to ans3.
Then 13 digits are read into score, the next digit (up to the following blank) is read into last_name, and the first three characters of "raje" are read into ans1 to ans3.
Then the first 13 characters are read as missing value into score, and the colon modifier for the $10. informat causes a skip to the next line (the padding is read as one delimiter!), so "95" is read into last_name, and the first three characters of "scerbo" end up in ans1 to ans3.
You need to pay attention to details.
12345678901234 is 14 digits. If you read it using an informat of 13. it reads the first 13 digits and then the 4 at the end of the number is the first character of Last_Name.
if my question is not clear to you, i am so sorry.
first observation, ans1-ans3 varibles values are empty and guessed those should read in the next line but due to default length is 80 and there is no : operator, it will not read next row values.
@rajeshm wrote:
if my question is not clear to you, i am so sorry.
first observation, ans1-ans3 varibles values are empty and guessed those should read in the next line but due to default length is 80 and there is no : operator, it will not read next row values.
Exactly.
instead of raising another related query here, raised in different thread as this query is already resolved.
expecting answer from you.
https://communities.sas.com/t5/New-SAS-User/list-input-missing-varible-values-reason2/m-p/686104
can you give me hint ,in which case program will read second row for first observation varibles and in which case it is not. still confusing..
DATALINES are automatically padded (with blanks) to 80 characters. Since you do not use the colon modifier for the $1. informat, blanks are read from zhe padding of the first line into ans1 to ans3.
Then 13 digits are read into score, the next digit (up to the following blank) is read into last_name, and the first three characters of "raje" are read into ans1 to ans3.
Then the first 13 characters are read as missing value into score, and the colon modifier for the $10. informat causes a skip to the next line (the padding is read as one delimiter!), so "95" is read into last_name, and the first three characters of "scerbo" end up in ans1 to ans3.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.