DATA Step, Macro, Functions and more

Reading raw data column input issue

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

Reading raw data column input issue

I have submitted below program , but its showing invalid data for variable 'sal'

 

data Emp;
informat sal comma8.;
input name $ 1-4 sal 5-9 ;
datalines;
John12,360
;
run;

 

what is the issue?


Accepted Solutions
Solution
‎02-12-2016 04:42 PM
Respected Advisor
Posts: 3,799

Re: Reading raw data column input issue

Understanding Column Input

With column input, data values occupy the same fields within each data record. When you use column input in the INPUT statement, list the variable names and specify column positions that identify the location of the corresponding data fields. You can use column input when your raw data is in fixed columns and does not require the use of informats to be read.
 

View solution in original post


All Replies
Super User
Posts: 19,771

Re: Reading raw data column input issue

The input statement is incorrect, you'rer trying to use fixed format method to read the file. Your data appears to be comma delimited instead. Specify the delimiter using DLM. 

 

Infile cards dlm=",";

Input name $ sal;

 

 

Contributor
Posts: 44

Re: Reading raw data column input issue

If you just put the start column ans informat into input line it works.

 

data Emp;
informat sal comma6.;
input name $ 1-4 @5 sal comma8. ;
datalines;
John12,360
;
run;

 

 

Solution
‎02-12-2016 04:42 PM
Respected Advisor
Posts: 3,799

Re: Reading raw data column input issue

Understanding Column Input

With column input, data values occupy the same fields within each data record. When you use column input in the INPUT statement, list the variable names and specify column positions that identify the location of the corresponding data fields. You can use column input when your raw data is in fixed columns and does not require the use of informats to be read.
 
Contributor
Posts: 24

Re: Reading raw data column input issue

Thanks all for replying. Now i understand that in column input, informats are ignored.

Thanks.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 269 views
  • 1 like
  • 4 in conversation