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-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
  • 2 replies
  • 772 views
  • 2 likes
  • 3 in conversation