please tell me right code
Data test_Call_Duration_correction ;
Infile 'D:\ANALYTICS.SAS\TEST.ASSIGMENT1 to 8\Daily_call_duration.txt' ;
input sept11 ddmmyy7. usage1 oct11 ddmmyy7. usage2 nov11 ddmmyy7. usage3 dec11 ddmmyy7. usage4
;
RUN;
It is always best to just post your sample data as text in the question. Use the Insert Code icon on the editor menu.
So here are a few lines from your file (at least how they look when viewed on this site).
1Sep11 389.00 1Oct11 491.00 1Nov11 370.00 1Dec11 335.00 2Sep11 423.00 2Oct11 478.00 2Nov11 407.00 2Dec11 442.00 3Sep11 482.00 3Oct11 300.00 3Nov11 303.00 3Dec11 372.00 10Sep11 484.00 10Oct11 364.00 10Nov11 491.00 10Dec11 455.00 11Sep11 485.00 11Oct11 456.00 11Nov11 451.00 11Dec11 479.00
So given that your program looks close. Since the values are not in fixed columns, but they do appear to be separated by spaces (and all have a value) then simple list mode input statement should work. For that you either need to not include any informat specifications in the INPUT statement, or add the : prefix in from of them.
Your variable names seem a little silly.
The main issues are the lack of the : modifier and you are using the wrong informat. Plus you should add a FORMAT statement so you can understand the date values when they print. Without the format statement the date values will just display as the number of days since 1/1/1960 and that will be hard for humans to understand.
data test_Call_Duration_correction ;
infile 'D:\ANALYTICS.SAS\TEST.ASSIGMENT1 to 8\Daily_call_duration.txt' ;
input sept11 :date. usage1 oct11 :date. usage2 nov11 :date. usage3 dec11 :date. usage4;
format sept11 oct11 nov11 dec11 yymmdd10. ;
run;
Are you sure you wouldn't rather just read that data as two variables per observation, DATE and USAGE. But that it just happens to be wrapped into the text file with four observations per row?
data test_Call_Duration_correction ;
infile 'D:\ANALYTICS.SAS\TEST.ASSIGMENT1 to 8\Daily_call_duration.txt' ;
input date :date. usage @@ ;
format date yymmdd10. ;
run;
You can add a PROC SORT step afterwards to get the observations in DATE order.
thanks tor the help.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.