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.
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 25. Read more here about why you should contribute and what is in it for you!
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.