@BrahmanandaRao wrote:
pleas provide link
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/pgmsashome/home.htm, section Data Step Programming.
Use these options in your INFILE statement:
termstr=CR
dlm=","
firstobs=2
dsd
truncover
This file was quite obviously created on a Mac.
You need to use an actual variable name in your code, not gibberish like this:
where POS Consumer Price=0
That code has three names POS, Consumer, and Price without any operators between them.
If you use PROC IMPORT with VALIDVARNAME option set to V7 then a COLUMN with a header of 'POS Consumer Price' will become a VARIABLE named POS_Consumer_Price.
So use
where POS_Consumer_Price=0
in the code.
If you accidentally ran the PROC IMPORT with VALIDVARNAME set to ALL then you will have to use a name literal in your code.
where 'POS Consumer Price'n=0
Your file appears to be using a bare CR as the end of line marker.
NOTE: The infile CSV is: (system-specific pathname), (system-specific file attributes) RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 Rest Owner,Rest Coop,REST_KEY,MITM_KEY,Menu Item,Menu Item Combo Meal Flag,Reporting Day,POS Consume 101 r Price,POS Total Units Sold Promo and Regular,POS Promotion Units Sold,POS Units Sold,POS Combo Un 201 its Sold.SMITH JOE,SEA/TCA WA CP-0024,1364,1,00000001-REUBEN,N,1/1/11,0.95,25,0,25,6.SMITH JOE,SEA/T ZONE 6772566605445424442544254425424523333233332323333333325454442423232332323323323233230544542444254425 NUMR 94303FC4D3D9480AF5C351F431071030D0024C1364C1C00000001D25525ECEC1F1F11C0E95C25C0C25C6D3D9480AF5C351F4
So make sure to tell SAS that before trying to use PROC IMPORT to GUESS how to read the file.
filename csv "C:\downloads\Product Sales_Candidate Attach 1_PresSE_013.csv"
termstr=cr
;
proc import file=csv dbms=csv out=want replace;
run;
NOTE: 6516 records were read from the infile (system-specific pathname). The minimum record length was 72. The maximum record length was 94. NOTE: The data set WORK.WANT has 6516 observations and 12 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 6516 rows created in WORK.WANT from CSV.
Note that there is still a bug in Excel on a Mac where it does not understand that MacOS is now a flavor of Unix and it should use LF as the end of line marker. If you want to convert a spreadsheet to a CSV file on a Mac make sure to select the right file format so that it makes a file that use LF or CRLF as the end of line marker.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.