BookmarkSubscribeRSS Feed
hiteshchauhan1
Obsidian | Level 7

Hi,

 

I am a little confused right now about something i need to do but have no clue of how to do this. Posting it here to get ideas from SAS experts and to open a discussion about what i want to do.

So, a little bit of background of what was happening till now and later i will tell you what i want to do now.

Background: There is a sas program that changes every month, the changes that happen are not major just some additions or deletions from if statement. And due to the same reason we have to save that program with the Year and  month name at the end (YYMM). To keep track of what changed in which YYMM. 

 

What i want to do: I want to get rid of this and want a single program which can be run for those periods and will have changes according to the Year and month.

 

What are the ways to do this? I don't have much knowledge of all that SAS can do but i am interested in learning.

 

Initial Thought: I was thinking if i can create  table which will have logic based on YYMM date and i can call logics from that table to my program based on a macro variable which is basically the date(YYMM). But i am not sure if this can be done in sas or not. 

 

Let me know your ideas in the answer box.

 

 

Thanks,

6 REPLIES 6
smantha
Lapis Lazuli | Level 10

a sample of what the business  logic looks like will be helpful. You might not need a table to write the logic unless you want to keep track of the changes.

AhmedAl_Attar
Rhodochrosite | Level 12

Why not using Source Code Version Control such as SVN, Git, Github?

This is not specific to SAS programs, and you can have all your team members, if you have any, accessing and using the same repository, without emailing files around, and keeping multiple copies on their disks.

 

Just a thought,

Hope this helps,

Ahmed

Quentin
Super User

As @AhmedAl_Attar  said, I think your real problem statement is:


Background: There is a sas program that changes every month, the changes that happen are not major just some additions or deletions from if statement. And due to the same reason we have to save that program with the Year and  month name at the end (YYMM). To keep track of what changed in which YYMM. 

This is what version control software is for.  You do not need to store a history of changes in your .sas file, and do not need to have a separately named .sas file for each year/month.  There is a learning curve to getting started with version control, but it could change your life. : )

 

Even if you want to be able to re-run the program from March, any version control software will pull an old version, any time you want.  You don't need to keep all the logic for every historic month in the same program.

BASUG is hosting free webinars ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.
ed_sas_member
Meteorite | Level 14

Hi @hiteshchauhan1 

What come up to my mind is something like this:

- create a macro-program with Year, month as parameters, as well as things that changes in the program (ex. a value in an IF statement, etc.)

- create a dataset that contain one observation per couple Year - month + things that changes in the program in one or more variables

- use CALL EXECUTE or DOSUBL function to execute the macro-program based on the values of the dataset

 

Best,

Kurt_Bremser
Super User

You can do this with %if %then %do-%end blocks, since SAS 9.4 M6 (or M5) in open code:

%let yymm = 2006;

/* later in the code *

if
%if &yymm. = 2005 %then %do;
  sky = "blue"
%end;
%if &yymm. = 2006 %then %do;
  sky = "grey"
%end;
then put "This is how it works";

/* further code */
ballardw
Super User

Example of code.

Indicate what changes.

Indicate WHY it changes.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 653 views
  • 3 likes
  • 7 in conversation