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;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 272 views
  • 0 likes
  • 2 in conversation