Hello everyone:
Could someone please assist me to write a macro in SAS Studio that will allow me to create temporary datasets and run proc logistic for three pairwise comparisons? I would like to have the datasets be tmp13, tmp23, and tmp12, respectively, with the numbers representing treatment assignments (i.e., trt01pn can equal 1, 2, or 3). Within each dataset, I need to create a variable trt such that if trt01pn = the first number in the data step after tmp then trt = 1; else if trt01pn = the second number in the data step after tmp then trt = 0. I later need to create three datasets, say data13, data23, and data12, in which one of tmp13, tmp23, or tmp12 is each used one time together with tmpcopy0 and tmpcopy1. The trt variable = 0 for tmpcopy0 and 1 for tmpcopy1, so these will not vary by treatment. Next, I need to use each of data13, data23, and data12 in proc logistic with each producing a separate output, for instance out = pred13 in one proc logistic, out = pred23 in another, and out = pred12 in the last logistic. Lastly, from pred13, pred23, and pred12, I need to create two datasets each, such as pred113 and pred013 for pred13, pred123 and pred023 for pred23, and pred112 and pred012 for pred12. I have placed the code needed for the trt01pn = 1 vs trt01pn = 3 comparison below, realizing I could do the above with a series of copy and pastes, but want to learn how to write this through a macro. Thank you for your help! 🙂
Instructions:
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
https://support.sas.com/resources/papers/proceedings13/120-2013.pdf
I would imagine it would be best if you followed these instructions, and come back and ask questions if you get stuck
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.
Ready to level-up your skills? Choose your own adventure.