I am reading csv files using infile statement
From what you've shown initially this works. It seems like your actual problem may be a bit different, in that case this may or may not work.
data have;
informat cumulative_premium dollar. medical_expenses dollar. renewaldt mmddyy10.;
format cumulative_premium medical_expenses dollar12. renewaldt date9.;
input Cumulative_premium Medical_Expenses Renewaldt;
cards;
$123,456 $456,876 3/1/2019
$786,000 $657,999 3/1/2019
$786,909 $678,000 3/15/2019
;;;;
run;
proc print data=have;
run;
@Srivikasheeba wrote:
infile "path";
ENCODING = "LATINI"
PAD
DLM=' , '
MISSOVER
DSD FIRSTOBS=2;
This is my code before length statement
Hello reeza ,thanks for the reply, date9. just changed the date format but the error still persists , now my date value is
01JAN2019
but the secound date is still missing and this is read .9 in next column, where it shouldnt read
Renewaldt Rent
01JAN2019
. 9
problem is program not reading correctly the dates
date 1:1/1/2019
date2:1/15/2019
if i give mmddyy8. only 1/1/2019 reads but other date moves to rent column and reads as .9 (which is the 9 in 2019)
if I give mmddyy9. only 1/15/2019 reads but date1 is missing
how can I read both @ once?
Here's an idea, show use some of your actual lines of data. Copy the lines with the header and maybe 5 lines of data. On the forum open a text box using the </> icon and paste the data.
BTW, if you opened the file in a spreadsheet and then saved on closing you may have just changed the original contents of the cells.
Or copy the log from running or code for the entire step reading the data including all notes and warnings and again paste into a text box.
The message windows reformat text quite a bit.
; Input Cumulative premium$ Medical Expenses$ Renewaldt ANYDTDTE10. ;
would attempt to read in 5 variables: Cumulative (as numeric), premium as character, Medical (as numeric), Expenses as character and then the Renewaldt. If the source is as you describe then by the time you get to Medical all of the data columns have been "used" and then Expenses and Renewaldt should generate the ever popular "read on next line" warning.
Standard SAS variable names cannot have spaces in them. If you want to use "extended" names and the system options are set to allow it you would have to use "Cumulative Premium"n to reference a single variable. The quotes and n needed every place you attempt to use the variable.
What you posted is positively NOT a csv file at all. In Comma Separated Volumes, data items have to be separated by commas, not arbitrary numbers of blanks.
Open your file with a text editor (NOT with Excel!), copy the first few lines, and paste them into a code box opened with the </> button. Do not skip this.
Only when we can see your real data will we be able to help you.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.