DATA Step, Macro, Functions and more

problem infile statement

Occasional Contributor
Posts: 5

problem infile statement

I converted xls file into txt and then i wrote a code to infile that file but i am not getting results and the log windows is showing garbage values.


data online;
infile "/folders/myfolders/OnlineShopping.txt"
input C_ID Product_ID P_CATEGORY $ CONDTION $ Brand $ Price Selling_price;
title 'online shopping';
proc print data=online;

Respected Advisor
Posts: 2,839

Re: problem infile statement

So, if you're not getting the results you want, and you also want our help, we'd need to see the input data (or a relevant portion of it) as well as the output results that aren't what you want.

Paige Miller
Occasional Contributor
Posts: 5

Re: problem infile statement

Posted in reply to PaigeMiller

input data(small portion of the whole data)



the wrong output 


  Obs C_ID Product_ID P_CATEGORY CONDTION Brand Price Selling_price 1 2 3 4 5 6 7

..card 3046679 396carrier..
..Sports Mcard 5866740 844..
..5974 470card 2887759 266..
..NorthFace GH6carrier..
..carrierBilling3723 710..
..carrierBilling6565 396..
Super User
Posts: 23,346

Re: problem infile statement

Try using a PROC IMPORT instead. Set the GUESSINGROWS option to the number of rows that you have. 

The log will have the data step code that you need and you can compare it to your non-working code.

Super User
Posts: 13,358

Re: problem infile statement

Unexpected output? Provide input data in the form of an attached text file or just pasted into a code box, the actual results and the expected results.


I would suggest that saving as CSV would be a better choice than TXT as you may end up with tab delimited and your code doesn't show any delimeter. I would expect not to get the desired result. With the CSV try using the import wizard or proc import and then examine the datastep code that will appear in the log. I often then copy the code from the log and modify where needed to allow longer variables, change things that appear to be numeric but should be character or the other way around and such.

Ask a Question
Discussion stats
  • 4 replies
  • 4 in conversation