BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

Hi, 

I have a report that I need to create each month.

The problem I'm facing when I'm trying to program it, I'm finding difficulties bc for the following reason. 

this is a sample of the dataset and the program; 

 

 

TaskStatusCompleteDate
Assigned 
Assigned 
Assigned 
Assigned 
Assigned 

 

data Asterias2;
set Asterias1; 

if taskstatus="Assigned" and completedate="  "  then count=1; 

run; 

 

%let thismonthn=%sysfunc(today(),MONNAME.) ;
%put &thismonthn;

 

proc sql;
create table Asterias3 as
select
 sum(count) as &thismonthn
from asterias2;
quit;

 

the problem I'm having that I'm having I need to create the variable  &thismonthn and  I also want to be able to store the outcomes 

and the next month when I run the program again I will have &thismonmthn and prior month 
 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The easiest way to store data is in a permanent SAS data set, then it can be used in future runs of the program.

 

But this part isn't really clear

 

the problem I'm having that I'm having I need to create the variable  &thismonthn and  I also want to be able to store the outcomes 

and the next month when I run the program again I will have &thismonmthn and prior month 

 

Do you mean you want the count and the month to be stored, and the values from previous months also stored in the same place?? If so, you could certainly use PROC APPEND to add the current months results to the results of previous months.

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

The easiest way to store data is in a permanent SAS data set, then it can be used in future runs of the program.

 

But this part isn't really clear

 

the problem I'm having that I'm having I need to create the variable  &thismonthn and  I also want to be able to store the outcomes 

and the next month when I run the program again I will have &thismonmthn and prior month 

 

Do you mean you want the count and the month to be stored, and the values from previous months also stored in the same place?? If so, you could certainly use PROC APPEND to add the current months results to the results of previous months.

--
Paige Miller
mona4u
Lapis Lazuli | Level 10
next month I have to create a variable of the current month and I have to have the variable of the prior month too
PaigeMiller
Diamond | Level 26

Here's what you get with PROC APPEND, does this meet your needs?

 

MONTH      COUNT
012018             38
022018             57
032018             45
...
--
Paige Miller
mona4u
Lapis Lazuli | Level 10
I'm Joining the dataset horizontally
PaigeMiller
Diamond | Level 26

Show us an example of what you want, for say three or four months of results.

--
Paige Miller
mona4u
Lapis Lazuli | Level 10

I got the idea. 

Thanks 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 790 views
  • 2 likes
  • 2 in conversation