Hello,
I would like to create a monthly report based on the date from Jan to Apr 2023. Please help. In addition, there are errors in creating the dataset. Please correct them; thanks.
data test;
input cust_id date :ddmmyy10. site;
format date ddmmyy10.;
infile datalines delimiter=',';
datalines;
2,01/04/2023,1,
6,01/24/2023,1,
3,03/04/2023,2,
8,03/18/2023,1,
4,02/05/2023,1,
7,04/05/2023,1
;
run;
data Monthly_Table;
input Site Jan2023 Feb2023 Mar2023 Apr2023;
infile datalines delimiter=',';
datalines;
1,2,1,0,1,
2,0,0,1,0,
;
Are your dates supposed to be MONTH DAY YEAR or DAY MONTH YEAR? You use a ddmmyy informat but have values for "month" of 24. That is a data fix, not code, unless you specified the wrong informat. But we don't know what would be "right". So can't fix the code.
If that data is supposed to be Jan to April then you have MONTH DAY YEAR data and the informat should be mmddyy10.;
Now, describe the report results. Please don't make use guess. And is this supposed to be a report that people read and not a data set?
data test; input cust_id date :mmddyy10. site; format date mmddyy10.; infile datalines delimiter=','; datalines; 2,01/04/2023,1, 6,01/24/2023,1, 3,03/04/2023,2, 8,03/18/2023,1, 4,02/05/2023,1, 7,04/05/2023,1 ; run; proc tabulate data=test; class date site; format date monyy7.; table site, date*n=' ' /misstext='0' ; run;
Are your dates supposed to be MONTH DAY YEAR or DAY MONTH YEAR? You use a ddmmyy informat but have values for "month" of 24. That is a data fix, not code, unless you specified the wrong informat. But we don't know what would be "right". So can't fix the code.
If that data is supposed to be Jan to April then you have MONTH DAY YEAR data and the informat should be mmddyy10.;
Now, describe the report results. Please don't make use guess. And is this supposed to be a report that people read and not a data set?
data test; input cust_id date :mmddyy10. site; format date mmddyy10.; infile datalines delimiter=','; datalines; 2,01/04/2023,1, 6,01/24/2023,1, 3,03/04/2023,2, 8,03/18/2023,1, 4,02/05/2023,1, 7,04/05/2023,1 ; run; proc tabulate data=test; class date site; format date monyy7.; table site, date*n=' ' /misstext='0' ; run;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.