BookmarkSubscribeRSS Feed
anitapamu2
Calcite | Level 5

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

3 REPLIES 3
Tom
Super User Tom
Super User

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 602 views
  • 0 likes
  • 4 in conversation