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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.