BookmarkSubscribeRSS Feed
Sean_Nadasky
Calcite | Level 5

So I have the following code entered into SAS Enterprise Guide.  I'm curious how we can get around this error and successfully create a decision tree from the data.  Any suggestions?
/* --------------------------------------------------------------------
Code generated by a SAS task

Generated on Wednesday, June 8, 2022 at 6:47:04 PM
By task: Import Data Wizard

Source file: C:\Users\seann\Downloads\09_AHRF2021 (1).xlsx
Server: Local File System

Output data: WORK.09_AHRF2021 (1)
Server: SASApp

Note: In preparation for running the following code, the Import
Data wizard has used internal routines to transfer the source data
file from the local file system to SASApp. There is no SAS code
available to represent this action.
-------------------------------------------------------------------- */

/* --------------------------------------------------------------------
This DATA step reads the data values from a temporary text file
created by the Import Data wizard. The values within the temporary
text file were extracted from the Excel source file.
-------------------------------------------------------------------- */

DATA WORK.'09_AHRF2021 (1)'n;
LENGTH
County $ 30
HPSA_PrimaryCare_Code 8
HPSA_Dental_Code 8
HPSA_MentalHealth_Code 8
MDs_Active 8
MDs_Inactive 8
NPs 8
Poverty_Persisitant 8
Uninsured_u65 8
Uninsured_18_64 8
Uninsured_40_64 8
Uninsured_u19 8
Population_Total 8
MetroCounty 8
Population_Density 8
MDActive_per1000 8
NP_per1000 8
Rural 8
Micro 8
Metro 8
MDActive_per1000_Winz 8
NP_per1000_Winz 8
HPSA_PrimaryCare $ 5
HPSA_Dental $ 5
HPSA_MentalHealth $ 5 ;
FORMAT
County $CHAR30.
HPSA_PrimaryCare_Code BEST12.
HPSA_Dental_Code BEST12.
HPSA_MentalHealth_Code BEST12.
MDs_Active BEST12.
MDs_Inactive BEST12.
NPs BEST12.
Poverty_Persisitant BEST12.
Uninsured_u65 BEST12.
Uninsured_18_64 BEST12.
Uninsured_40_64 BEST12.
Uninsured_u19 BEST12.
Population_Total BEST12.
MetroCounty BEST12.
Population_Density BEST12.
MDActive_per1000 BEST12.
NP_per1000 F12.2
Rural BEST12.
Micro BEST12.
Metro BEST12.
MDActive_per1000_Winz BEST12.
NP_per1000_Winz F12.2
HPSA_PrimaryCare $CHAR5.
HPSA_Dental $CHAR5.
HPSA_MentalHealth $CHAR5. ;
INFORMAT
County $CHAR30.
HPSA_PrimaryCare_Code BEST12.
HPSA_Dental_Code BEST12.
HPSA_MentalHealth_Code BEST12.
MDs_Active BEST12.
MDs_Inactive BEST12.
NPs BEST12.
Poverty_Persisitant BEST12.
Uninsured_u65 BEST12.
Uninsured_18_64 BEST12.
Uninsured_40_64 BEST12.
Uninsured_u19 BEST12.
Population_Total BEST12.
MetroCounty BEST12.
Population_Density BEST12.
MDActive_per1000 BEST12.
NP_per1000 BEST12.
Rural BEST12.
Micro BEST12.
Metro BEST12.
MDActive_per1000_Winz BEST12.
NP_per1000_Winz BEST12.
HPSA_PrimaryCare $CHAR5.
HPSA_Dental $CHAR5.
HPSA_MentalHealth $CHAR5. ;
INFILE '/saswork/SAS_work64DD000114B5_odaws01-usw2.oda.sas.com/#LN00010'
LRECL=147
ENCODING="UTF-8"
TERMSTR=CRLF
DLM='7F'x
MISSOVER
DSD ;
INPUT
County : $CHAR30.
HPSA_PrimaryCare_Code : BEST32.
HPSA_Dental_Code : BEST32.
HPSA_MentalHealth_Code : BEST32.
MDs_Active : BEST32.
MDs_Inactive : BEST32.
NPs : BEST32.
Poverty_Persisitant : BEST32.
Uninsured_u65 : BEST32.
Uninsured_18_64 : BEST32.
Uninsured_40_64 : BEST32.
Uninsured_u19 : BEST32.
Population_Total : BEST32.
MetroCounty : BEST32.
Population_Density : BEST32.
MDActive_per1000 : BEST32.
NP_per1000 : BEST32.
Rural : BEST32.
Micro : BEST32.
Metro : BEST32.
MDActive_per1000_Winz : BEST32.
NP_per1000_Winz : BEST32.
HPSA_PrimaryCare : $CHAR5.
HPSA_Dental : $CHAR5.
HPSA_MentalHealth : $CHAR5. ;
RUN;

ods graphics on;

proc hpsplit seed=12345;
class MetroCounty Population_Density MDActive_per1000;
model MetroCounty Population_Density MDActive_per1000;

run;

7 REPLIES 7
Tom
Super User Tom
Super User

What is the question?

Your topic mentions an error but you have not shown any part of a SAS log so we have no idea what might be causing the error.

 

When posting text or SAS code please use the Insert Code or Insert SAS Code icon/button to get a pop-up window to paste/edit the text.  That will prevent the forum editor from thinking you are trying to type in paragraphs.

Tom_0-1654827885955.png

 

Sean_Nadasky
Calcite | Level 5
ods graphics on;

proc hpsplit seed=12345;
class MetroCounty Population_Density MDActive_per1000;
model MetroCounty Population_Density MDActive_per1000;

run;

That bit of code is my main focus. I have the original data set (which is the above data prior to this bit of code). I am trying to make a data tree. I have come to understand that a need a "data=", however, I am stumped on where I would find that to proceed the variables I'm trying to input on my decision tree (those variables being MetroCounty, Population_Density and MDActive_per1000)
ballardw
Super User

Here is what my log looks like from running your Proc Hpsplit code. Since the last data set created I have does not have your variables there are errors of variable not found. However look at the highlighted text:

379  proc hpsplit seed=12345;
NOTE: Writing HTML Body file: sashtml.htm
380  class MetroCounty Population_Density MDActive_per1000;
ERROR: Variable METROCOUNTY not found.
ERROR: Variable POPULATION_DENSITY not found.
ERROR: Variable MDACTIVE_PER1000 not found.
381  model MetroCounty Population_Density MDActive_per1000;
                       ------------------
                       73
ERROR: Variable METROCOUNTY not found.
ERROR 73-322: Expecting an =.
382
383  run;
ERROR: Variable POPULATION_DENSITY not found.
ERROR: Variable MDACTIVE_PER1000 not found.

The underscores under Population_density are telling you where SAS expected the = sign and what it found instead.

The MODEL statement requires an = to tell SAS which variable is the response and which variable(s) are the predictors.

From the documentation:

MODEL Statement

  • MODEL response <(response-option)> = variable <variable...>;

Solution: Place an = after the Metrocounty on the model statement.

model MetroCounty = Population_Density MDActive_per1000;

 

 

Patrick
Opal | Level 21

Is there eventually a data=<some table> missing so your procedure "knows" where to pick the variables from?

Sean_Nadasky
Calcite | Level 5
Would that be "DATA WORK.'09_AHRF2021 (1)'n;" from the first line?
Sean_Nadasky
Calcite | Level 5

Thank you, however MetroCounty is one of the variables we want in the decision tree

ballardw
Super User

@Sean_Nadasky wrote:

Thank you, however MetroCounty is one of the variables we want in the decision tree


If you want to use MetroCounty as a PREDICTOR then you need another variable as a RESPONSE variable. The syntax for the procedure's Model statement requires it.

If you do not have a valid response variable you need some completely different approach as the chosen procedure won't do what you are asking.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 1390 views
  • 0 likes
  • 4 in conversation