BookmarkSubscribeRSS Feed
ArchanaSudhir
Obsidian | Level 7

HI,

I have a dataset with various variables. Like Ethnicity, region, smoking.

Ethnicity - Asian, white, others.
Region - India, London, Manilla, Australia.
Smoking & non smoking


I have to run Proc phreg of reference versus others.

For example, If ref is Inida, I have to do
India vs London & India vs Manlla, India vs Australia.

If reference is smoking, smoking vs nonsmoking.

If reference for ethnicity is white, I have to do white vs Asian and white vs others.


The reference changes - sometimes it is first, sometimes it is 2nd, 3rd etc. There can be multiple levels as well( 2 to 5 levels).

 

How do I write a common code to fit all scenarios?

Thanks,
Archana

4 REPLIES 4
Reeza
Super User

I'm not sure how your writing your code but proc Phreg allows to explicitly specify the level, though that means you need to explicitly set each. Since your rules are different that's probably the best method.  

ArchanaSudhir
Obsidian | Level 7

HI Reeza,

 

Thanks for the quick reply.

 

I am using the PROC PHREG, specifying the reference range. But I have 12 programs and each one has reference parameter as a different parameter(1st, 2nd etc).

 

So, if the reference is parameter is India.

 India(1), London(2), Manilla, I have to do 1 vs 2 and 1 vs 3.

 

If the reference parameter is Whhite(2), I have to do 2 vs 1 and 2 vs 3.

 

I have to follow the same order as I have to match production output.

 

So instead of writing 12 different codes for each scenario, I was wondering if anything can be done to make a common code.

 

Thank,

Archana

ballardw
Super User

Not impossible but since this is "to match production output" you would need to read a description document or data set that says which reference levels are needed for each variable and in what order.

 

If you could get a data set to contain the needed information organized in a "nice" manner for the options you want, then it would be possible to use Call execute to generate the code.

 

But if the order and variables don't change from run to run then you'd likely be better off writing code directly.

 

You would have to provide the complete code that you are currently using and what kind of likely changes to get more specify help.

 

 

Reeza
Super User

How are you generating your odds ratio?

Using the Oddsratio statement or some other method?

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1178 views
  • 0 likes
  • 3 in conversation