BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

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,
;   

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

 

View solution in original post

1 REPLY 1
ballardw
Super User

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;

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 637 views
  • 1 like
  • 2 in conversation