At the simplest level, suggest you create a Portfolio variable for identification and divide your "dataset 2" observations equally based on the value of Sales. A DATA step or PROC SQL can perform this task - a macro approach would only benefit if you had a large number of Portfolio splits to generate - so start simple and use the technique involving: IF THEN ; SAS coding.
Then create a SAS file with a subset of key variables needed to compare "dataset 1" to "dataset 2" -- one additional variable is OBSNUM = _N_; to track the source observation.
Then perform your cross-check between "dataset 1" and "dataset 2", using the key-variables to determine where you a relationship in your data.
Lastly, using the results of your cross-check, retrieve the observations from your "dataset 1" and identify your closest_peer within "dataset 2".
Suggest you start programming, one step at a time -- then come back to the forum for suggestions and guidance with any particular problem you might have. You may find PROC SQL to be more comfortable for coding, but do consider that you have more control when using individual DATA step and PROC (SORT or otherwise) invocations, in many cases.
Make use of the SAS support website http://support.sas.com/ for helpful SAS-hosted DOC and also supplemental technical /
conference subject-matter reference materials.
Editor's note: in the time since this original post, @Reeza has contributed a useful article with code you can use.
Scott Barry
SBBWorks, Inc.
At the simplest level, suggest you create a Portfolio variable for identification and divide your "dataset 2" observations equally based on the value of Sales. A DATA step or PROC SQL can perform this task - a macro approach would only benefit if you had a large number of Portfolio splits to generate - so start simple and use the technique involving: IF THEN ; SAS coding.
Then create a SAS file with a subset of key variables needed to compare "dataset 1" to "dataset 2" -- one additional variable is OBSNUM = _N_; to track the source observation.
Then perform your cross-check between "dataset 1" and "dataset 2", using the key-variables to determine where you a relationship in your data.
Lastly, using the results of your cross-check, retrieve the observations from your "dataset 1" and identify your closest_peer within "dataset 2".
Suggest you start programming, one step at a time -- then come back to the forum for suggestions and guidance with any particular problem you might have. You may find PROC SQL to be more comfortable for coding, but do consider that you have more control when using individual DATA step and PROC (SORT or otherwise) invocations, in many cases.
Make use of the SAS support website http://support.sas.com/ for helpful SAS-hosted DOC and also supplemental technical /
conference subject-matter reference materials.
Editor's note: in the time since this original post, @Reeza has contributed a useful article with code you can use.
Scott Barry
SBBWorks, Inc.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.