SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vitaaquaticus
Fluorite | Level 6

I am trying to figure out how to run a Box Cox transformation on a continuous response variable (Frond Length) when I do not have continuous explanatory variables (they all are categorical).

 

This link shows how to run a Box Cox transformation without an independent variable.(https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_transreg_se...)

 

However, I cannot seem to run the code that will read my specific dataset that also includes a column of zeros. It will return errors saying that my 'Frond.Length'n and 'Zero" are not found. I am not sure how to include a line of codes that will read my dataset (the one I wrote below is definitely wrong). How do I modify the code to do that?

 

Thanks!

 

My code below:

 

title 'Univariate Box-Cox';

   

   data WORK.Data_Final_noAugust_SS_0001;

   run;

 

proc transreg maxiter=0 nozeroconstant;

      model BoxCox('Frond.Length'n) = identity(Zero);

      output;

   run;

   

   proc univariate noprint;

      histogram 'Frond.Length'n t'Frond.Length'n;

   run;

   

   ods graphics off;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You should comment your code so we understand what you think is happening. 

 

Here's an example:

 

*this actually destroys the data_final_no_augst data set - you will need to recreate it;
   data WORK.Data_Final_noAugust_SS_0001;
   run;
 
*you do not have a data= statement here so you are not using any dataset so you will get the wrong results.  will default to the last used data sets which will not be the above one because it's gone;

proc transreg maxiter=0 nozeroconstant;
      model BoxCox('Frond.Length'n) = identity(Zero);
      output;
   run;

What you probably want:

This assumes you input data set is in a library called mydata. If it's not or you're not familiar with the concept of a library, you can revisit some of the earlier tutorials or check video.sas.com and working with your own files. 

 

   data WORK.Data_Final_noAugust_SS_0001;*newly created data set;
     SET mydata.data_final_noAugust_ss_001;*refers to input data set;
   run;
 
proc transreg data = data_final_noAugust_ss_0001 maxiter=0 nozeroconstant;
      model BoxCox('Frond.Length'n) = identity(Zero);
      output;
   run;

View solution in original post

2 REPLIES 2
Reeza
Super User

You should comment your code so we understand what you think is happening. 

 

Here's an example:

 

*this actually destroys the data_final_no_augst data set - you will need to recreate it;
   data WORK.Data_Final_noAugust_SS_0001;
   run;
 
*you do not have a data= statement here so you are not using any dataset so you will get the wrong results.  will default to the last used data sets which will not be the above one because it's gone;

proc transreg maxiter=0 nozeroconstant;
      model BoxCox('Frond.Length'n) = identity(Zero);
      output;
   run;

What you probably want:

This assumes you input data set is in a library called mydata. If it's not or you're not familiar with the concept of a library, you can revisit some of the earlier tutorials or check video.sas.com and working with your own files. 

 

   data WORK.Data_Final_noAugust_SS_0001;*newly created data set;
     SET mydata.data_final_noAugust_ss_001;*refers to input data set;
   run;
 
proc transreg data = data_final_noAugust_ss_0001 maxiter=0 nozeroconstant;
      model BoxCox('Frond.Length'n) = identity(Zero);
      output;
   run;
Ksharp
Super User

You could check PROC MCMC 's documentation, One of its example is about Box-Cox transformation.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1326 views
  • 2 likes
  • 3 in conversation