DATA Step, Macro, Functions and more

Why so output is like this ?

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Why so output is like this ?

Raw File :

---------10---------20---------30

72 95

 

SAS Program :

 

data test;

infile "Rawfile";

input @1 height 2. @4 weight 2;

run;

 

why weight variable is taking  a value specified to next to it (only single digit) instead of 95 from raw file.

 

Output is :
_____________
Height Weight

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

   95       2


Accepted Solutions
Solution
‎06-27-2016 12:58 AM
Super User
Posts: 5,503

Re: Why so output is like this ?

It's interpreted as taking the contents of column 2.  You could code:

 

input @4 col1 1 @4 col2 2;

 

The @4 is irrelevant, overridden by the later instructions.  COL1 will be the contents of column 1, and COL2 the contents of column 2.

View solution in original post


All Replies
Super User
Posts: 19,789

Re: Why so output is like this ?

Posted in reply to Attyslogin

Your missing a period at the end of your second format. 

 

If you exclude formats and @ position SAS will most likely read it correctly by default. 

Respected Advisor
Posts: 4,920

Re: Why so output is like this ?

@Reeza, yet the "2" didn't generate an error. How is it interpreted?

PG
Solution
‎06-27-2016 12:58 AM
Super User
Posts: 5,503

Re: Why so output is like this ?

It's interpreted as taking the contents of column 2.  You could code:

 

input @4 col1 1 @4 col2 2;

 

The @4 is irrelevant, overridden by the later instructions.  COL1 will be the contents of column 1, and COL2 the contents of column 2.

Respected Advisor
Posts: 4,920

Re: Why so output is like this ?

Posted in reply to Astounding

Oh yes! The old column input. The burden of legacy...

 

Thank you @Astounding!

PG
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 261 views
  • 4 likes
  • 4 in conversation