DATA Step, Macro, Functions and more

Macro

Reply
New Contributor
Posts: 4

Macro

Could someone PLEASE help me with the layout of the following : write a macro program that will ad information from dataset B (select only unique variables PT and CMPREF only) to patients (select unique PT values only) from dataset A and save results as dataset C. Run your macro for the following parameters: A= rawdata.adverse, B = rawdata.conmeds, C= derived.macro
Valued Guide
Posts: 596

Re: Macro

Posted in reply to Lombardc1

It would be a good idea to show us what you've tried so far along with some sample data - people on here are very helpful but they like to see you've actually made an attempt first Smiley Happy

New Contributor
Posts: 4

Re: Macro

Posted in reply to Lombardc1
I guess it would go something like:

data dataset C;
set dataset B dataset A;
run;

Proc print data = dataset C;
var PT CMPREF;
title "Dataset C CONATENATION"
run;
Valued Guide
Posts: 596

Re: Macro

Posted in reply to Lombardc1

Firstly that's not a macro

 

Secondly how are you ensuring only unique values are selected?

 

Thirdly hopw are you ensuring correct mayching by id?

 

Fourthly where are your parameters?

 

If you don't have sample data then create some, run your program to see what happens.......

Super User
Posts: 24,018

Re: Macro

Posted in reply to Lombardc1

Itemize your requirements.  

Break it into steps first.

Then get it working for a non macro situation. 

Then convert it into a macro.

Your current attempt is missing several of the criteria in the question .

i won't do your homework but happy to help debug. 

Super User
Posts: 13,941

Re: Macro

Posted in reply to Lombardc1

Macro programming involves determining what you need to do without any macro coding. Then adding the parameters to make the macro more "dynamic" or flexible than the fixed code for one case.

 

If you don't know how to do the case without a macro then starting with a macro is likely to end in a failure as the macro language basically is intended to write code to perform the process. So if you had the base code that would do one case we could show you where to make the changes suitable for a macro to process different data sets and variables.

Ask a Question
Discussion stats
  • 5 replies
  • 118 views
  • 0 likes
  • 4 in conversation