BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rajeshm
Quartz | Level 8
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;

rajeshm_2-1600777450229.png

 

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??

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
rajeshm
Quartz | Level 8

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.

Kurt_Bremser
Super User

@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.

rajeshm
Quartz | Level 8

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..

Kurt_Bremser
Super User

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.

rajeshm
Quartz | Level 8
Thanks a lot for the details explanation.
Due to : operator in Last_Name it skipped and read the value in next line(3rd row) ?
ans 1-answ 3 read the blanks in the same line as there is no : operator in (1st row)?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 683 views
  • 1 like
  • 3 in conversation