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;

 

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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