I am trying to write a macro to calculating days for the all the dataset in libaray

Reply
Contributor
Posts: 34

I am trying to write a macro to calculating days for the all the dataset in libaray

Please find the attached file and code file.

Source data library contains two data set  : DEMO and AEDATA.

transaction data library contain one data set Metadata (metadata consist of variable information for example  action = "DATE" and dy = "Y" then NumDays = intck( 'day', startdate, endday ); )

1) Want to merge the Demo data with the both data set form Source data library (DEMO and AEDATA.) [aim to add RFSTDTC variable in all the dataset in source library] .

2) Then want to merge the  data with metadata then according to  the condition the calculation of the dates should occur action = "DATE" and dy = "Y" then NumDays = intck( 'day', startdate, endday );

3) Want calculate the date (days) difference using common data set   ("DEMO. RFSTDTC").

Thanks,

Anita

Attachment
Attachment
Attachment
Attachment
Super User
Posts: 19,171

Re: I am trying to write a macro to calculating days for the all the dataset in libaray

Super User
Super User
Posts: 6,849

Re: I am trying to write a macro to calculating days for the all the dataset in libaray

Would you like to convert the dates to relative day number back into the same variables?

Or make new variables to hold the relative day numbers?  If so then how do propose generating names for all of these new variables?  Does your proposed algorithm insure that the generated names are unique and do not conflict with any existing variables in the data set?

You first need to show how you would do if for one case.  Then you can begin working on a macro that will generate the proper code.

Super User
Super User
Posts: 7,723

Re: I am trying to write a macro to calculating days for the all the dataset in libaray

Hi,

Well, a few things.  Firstly its not clear what your question is, am not writing a whole program.

Secondly, write the code to something once before you try to look at macro.  Macro is at the end of the day just a code generator, so you need to know what your code should look like.  Also, look at it from another point, is a macro really necessary, can you code or arrange the data in a different way to do something in straight code.  There are some circumstances, i.e. if you develop a macro for a team, where creating a macro is good, and then you would follow SDLC anyways which would detail your code more or less. 

For the points you make, its pretty much all about merging.  There are many documents on SAS help about this, various types of merging etc. Or you might consider SQL merges: A Visual Explanation of SQL Joins

As for calculating days difference you have numerous procedures INTCK for example, or if they are both dates just take one from the other.

Ask a Question
Discussion stats
  • 3 replies
  • 291 views
  • 0 likes
  • 4 in conversation