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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

4 REPLIES 4
Reeza
Super User

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. 

PGStats
Opal | Level 21

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

PG
Astounding
PROC Star

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.

PGStats
Opal | Level 21

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

 

Thank you @Astounding!

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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