DATA Step, Macro, Functions and more

store variable in the program

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 149
Accepted Solution

store variable in the program

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 
 


Accepted Solutions
Solution
4 weeks ago
Respected Advisor
Posts: 2,807

Re: store variable in the program

[ Edited ]

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


All Replies
Solution
4 weeks ago
Respected Advisor
Posts: 2,807

Re: store variable in the program

[ Edited ]

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
Frequent Contributor
Posts: 149

Re: store variable in the program

Posted in reply to PaigeMiller
next month I have to create a variable of the current month and I have to have the variable of the prior month too
Respected Advisor
Posts: 2,807

Re: store variable in the program

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

 

MONTH      COUNT
012018             38
022018             57
032018             45
...
--
Paige Miller
Frequent Contributor
Posts: 149

Re: store variable in the program

Posted in reply to PaigeMiller
I'm Joining the dataset horizontally
Respected Advisor
Posts: 2,807

Re: store variable in the program

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

--
Paige Miller
Frequent Contributor
Posts: 149

Re: store variable in the program

Posted in reply to PaigeMiller

I got the idea. 

Thanks 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 121 views
  • 2 likes
  • 2 in conversation