BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
kcvaldez98
Obsidian | Level 7

Hi SAS coders,

 

I am new to SAS and was wondering if it is possible to use labels as the variable names for a PROC REG?

 

Here's my code:

ODS NOPROCTITLE;
PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress)
PLOTS(ONLY) = FITPLOT;
MODEL Frequent_Mental_Distress = Marijuana_Use /
CLM
CLI
ALPHA=0.05;

TITLE "Linear Regression of Frequent Mental Distress and Marijuana Use";
ODS SELECT FitPlot;
RUN;
TITLE;

The output looks like this:

Screenshot 2023-12-04 102544.png

I want it to show that Marijuana_Use and Frequent_Mental_Distress is displayed as their labels and I also was wondering if I can delete the "Model: MODEL1" out?

Any help is appreciated.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

By "Use labels as variable names," I assume you want to use nice labels on the X and Y axes on the fit plot. If so, use the LABEL statement inside the PROC REG step, like this

 

PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress)
PLOTS(ONLY) = FITPLOT;
label Frequent_Mental_Distress= "Frequent Mental Distress"
      Marijuana_Use = "Marijuana Use (Grams per Day)";
 MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
ODS SELECT FitPlot;
quit;

It is possible to remove the MODEL : MODEL1 tag, but it is an advanced technique. Most people prefer to see a reasonable name for the model, such as follows:

options validvarname=any;
PROC REG... ;
/* specify a label before the MODEL keyword */
'Distress vs Marijuana'n:
MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
quit;

 

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

By "Use labels as variable names," I assume you want to use nice labels on the X and Y axes on the fit plot. If so, use the LABEL statement inside the PROC REG step, like this

 

PROC REG DATA=WORK.FIGURE (RENAME = outcomes_adults_mental_distr = Frequent_Mental_Distress)
PLOTS(ONLY) = FITPLOT;
label Frequent_Mental_Distress= "Frequent Mental Distress"
      Marijuana_Use = "Marijuana Use (Grams per Day)";
 MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
ODS SELECT FitPlot;
quit;

It is possible to remove the MODEL : MODEL1 tag, but it is an advanced technique. Most people prefer to see a reasonable name for the model, such as follows:

options validvarname=any;
PROC REG... ;
/* specify a label before the MODEL keyword */
'Distress vs Marijuana'n:
MODEL Frequent_Mental_Distress = Marijuana_Use / CLM CLI ALPHA=0.05;
quit;