Help using Base SAS procedures

Dynamic reference change

Reply
Contributor
Posts: 53

Dynamic reference change

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

Super User
Posts: 17,840

Re: Dynamic reference change

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.  

Contributor
Posts: 53

Re: Dynamic reference change

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

Super User
Posts: 10,500

Re: Dynamic reference change

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.

 

 

Super User
Posts: 17,840

Re: Dynamic reference change

How are you generating your odds ratio?

Using the Oddsratio statement or some other method?

 

Ask a Question
Discussion stats
  • 4 replies
  • 287 views
  • 0 likes
  • 3 in conversation