BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shubhamtiwari
Fluorite | Level 6

Hi,

 

Please help me to understand the following question, 

 

 

 Which SAS statement correctly uses column input to read the values in the raw data file below in this order: Address (4th field), SquareFeet (second field), Style (first field),
Bedrooms (third field)?

 

 

1--+----10---+----20---+----30

 

2STORY   5500 7 MUMBAI71 NEW

ALATE      2200 4 RANE STREET

MONTE    5200 3 MUKESH STREET


1. input Address 15-29 SquareFeet 8-11 Style 1-6
Bedrooms 13;
2. input $ 15-29 Address 8-11 SquareFeet $ 1-6 Style
13 Bedrooms;
3. input Address $ 15-29 SquareFeet 8-11 Style $ 1-6
Bedrooms 13;
4. input Address 15-29 $ SquareFeet 8-11 Style 1-6
$ Bedrooms 13;

 

 

 

 

Doubt=  what is the  1--+----10---+----20---+----30 means in the question? 

 

 

Please help 

 

thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@shubhamtiwari wrote:

@Kurt_Bremser  than you for the reply, but still i did not understood the meaning of those numbers  1,10,20,30

 

 

 

 

1--+----10---+----20---+----30

 

 

 

what if we have like this 5--+----15---+----19---+----44

 

 

here what does these numbers 5,15,19,44 represent?

 

 

Please elaborate.

 

 


1---+----10---+----20---+----30
2STORY   5500 7 MUMBAI71 NEW
         111111111122222222223
123456789012345678901234567890

The 3rd and 4th rows expand on the idea. Again important is to view things with a fixed width font

 

1

0

above indicates position number 10, of the first 5 in second row, The + are the values ending in 5 such as 15, 25

Position 20 is the B in Mumbai.

it is only a tool for counting columns. Nothing magic or difficult.

 

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

@shubhamtiwari wrote:

Hi,

 

Please help me to understand the following question, 

 

 

 Which SAS statement correctly uses column input to read the values in the raw data file below in this order: Address (4th field), SquareFeet (second field), Style (first field),
Bedrooms (third field)?

 

 

1--+----10---+----20---+----30

 

2STORY   5500 7 MUMBAI71 NEW

ALATE      2200 4 RANE STREET

MONTE    5200 3 MUKESH STREET


1. input Address 15-29 SquareFeet 8-11 Style 1-6
Bedrooms 13;
2. input $ 15-29 Address 8-11 SquareFeet $ 1-6 Style
13 Bedrooms;
3. input Address $ 15-29 SquareFeet 8-11 Style $ 1-6
Bedrooms 13;
4. input Address 15-29 $ SquareFeet 8-11 Style 1-6
$ Bedrooms 13;

 

 

 

 

Doubt=  what is the  1--+----10---+----20---+----30 means in the question? 

 

 

Please help 

 

thank you

 


This line is just a ruler for horizontal orientation. It becomes more useful when viewed with a fixed-space font:

1---+----10---+----20---+----30

2STORY 5500 7 MUMBAI71 NEW
ALATE  2200 4 RANE STREET
MONTE  5200 3 MUKESH STREET
shubhamtiwari
Fluorite | Level 6

@Kurt_Bremser  than you for the reply, but still i did not understood the meaning of those numbers  1,10,20,30

 

 

 

 

1--+----10---+----20---+----30

 

 

 

what if we have like this 5--+----15---+----19---+----44

 

 

here what does these numbers 5,15,19,44 represent?

 

 

Please elaborate.

 

 

Kurt_Bremser
Super User

1 is position 1 in the input line.

The "1" of "10" marks position 10 (the "0" is therefore position 11), and so on.

Only the 10s are been marked like that, so you won't see 5 or 15. This is also close to the way SAS puts a ruler into the log when it shows external data being read by a data step.

Run this code for reference:

filename test temp;

data _null_;
file test;
put "12345";
put "67890";
run;

data _null_;
infile test;
input;
list;
run;

filename test clear;

and read the log.

ballardw
Super User

@shubhamtiwari wrote:

@Kurt_Bremser  than you for the reply, but still i did not understood the meaning of those numbers  1,10,20,30

 

 

 

 

1--+----10---+----20---+----30

 

 

 

what if we have like this 5--+----15---+----19---+----44

 

 

here what does these numbers 5,15,19,44 represent?

 

 

Please elaborate.

 

 


1---+----10---+----20---+----30
2STORY   5500 7 MUMBAI71 NEW
         111111111122222222223
123456789012345678901234567890

The 3rd and 4th rows expand on the idea. Again important is to view things with a fixed width font

 

1

0

above indicates position number 10, of the first 5 in second row, The + are the values ending in 5 such as 15, 25

Position 20 is the B in Mumbai.

it is only a tool for counting columns. Nothing magic or difficult.

 

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1096 views
  • 1 like
  • 3 in conversation