BookmarkSubscribeRSS Feed
Lombardc1
Calcite | Level 5
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
5 REPLIES 5
ChrisBrooks
Ammonite | Level 13

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

Lombardc1
Calcite | Level 5
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;
ChrisBrooks
Ammonite | Level 13

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.......

Reeza
Super User

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. 

ballardw
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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