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"
firstobs=2;
input C_ID Product_ID P_CATEGORY $ CONDTION $ Brand $ Price Selling_price;
run;
title 'online shopping';
proc print data=online;
run;
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.
input data(small portion of the whole data)
C_ID | Product_ID | P_CATEGORY | CONDTION | Brand | Price | Selling_price |
4595 | 534 | SHOES | New | RKFCM | $1,484.74 | $1,471.74 |
6679 | 396 | LUGGAGE | New | TNVON | $1,452.50 | $1,442.50 |
7075 | 449 | SHOES | Refurbished | VKKEA | $4,308.02 | $4,284.02 |
1418 | 145 | BEDDING | New | PIUEM | $3,272.59 | $3,249.59 |
6740 | 844 | ELECTRONICS | Used | FMBZC | $628.67 | $608.67 |
4305 | 922 | LUGGAGE | New | IWPJG | $3,788.97 | $3,740.97 |
the wrong output
Obs C_ID Product_ID P_CATEGORY CONDTION Brand Price Selling_price 1 2 3 4 5 6 7
. | . | card 304 | 6679 396 | carrier | . | . |
. | . | Sports M | card 586 | 6740 844 | . | . |
. | . | Hardware | carrier | Billing | . | . |
. | . | 5974 470 | card 288 | 7759 266 | . | . |
. | . | North | Face GH6 | carrier | . | . |
. | . | carrier | Billing | 3723 710 | . | . |
. | . | carrier | Billing | 6565 396 | . | . |
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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.