BookmarkSubscribeRSS Feed
Sean_Nadasky
Calcite | Level 5

The below is the code that I have at this point in time.  I have been trying to create a basic decision tree, however I keep running into a ranging number of errors (from code already in use error to variables not able to be found errors).  I have tried to use a basic ods graphics on format (as seen in this video: https://www.google.com/search?q=how+to+create+a+decision+tree+in+sas+steps&sxsrf=ALiCzsZUorwUYhbGYw7...).  Any help would be greatly appreciated.

/* --------------------------------------------------------------------
   Code generated by a SAS task
   
   Generated on Saturday, June 11, 2022 at 8:24:04 AM
   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_work9C100000F890_odaws04-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;
5 REPLIES 5
ballardw
Super User

Large economy sized hint: When your question is about an error provide the LOG of the procedure or data step code with the code and all the messages. Copy the text from the log, on the forum open a text box using the </> icon that appears above the message window, paste the text. The text box helps preserve the diagnostic characters that SAS often provides related to errors.

 

Since we do not have your data set there is no way we can run your code and see the actual errors.

 

"Variable not found" errors often relate to either spelling errors or you modified a data set. Run proc contents on the data set used for input to verify names and existence.

 

"Code in use" is not a message I am familiar with, so really need to see it. DATA SET in use is quite common if you have the data set open in a view window and involves making sure that SAS or any other application is not using that file.

Sean_Nadasky
Calcite | Level 5
I appreciate your response, and as you can see above, the entire code is linked in the </> icon to insert the code seperate from my question. There were no errors in this code, the question was asking to create a decision tree out of the data in the code. The best I was able to create was using one where the Target Variable had to be of Binary Value
SASKiwi
PROC Star

I see you've previously posted on this topic and have included PROC HPSPLIT code to create a decision tree, but not in this post. Did your question have any more guidance than to "create a decision tree out of the data"?  Have you reviewed the PROC HPSPLIT documentation?

ballardw
Super User

@Sean_Nadasky wrote:
I appreciate your response, and as you can see above, the entire code is linked in the </> icon to insert the code seperate from my question. There were no errors in this code, the question was asking to create a decision tree out of the data in the code. The best I was able to create was using one where the Target Variable had to be of Binary Value

Confused as your initial post says "however I keep running into a ranging number of errors (from code already in use error to variables not able to be found errors)." Which says you are getting errors. So show the code getting the errors.

 

And we don't have your source file so this code doesn't do much.

Sean_Nadasky
Calcite | Level 5
Yes, to clarify: since I stated I was running into errors, I provided some example of those errors in the parenthesized section, there would not be any errors in the code I provided because that is the code for the data set, and not the code to create the decision tree. I did not provide you the errors because they are not relevant to the task at hand: creating a decision tree.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1212 views
  • 0 likes
  • 3 in conversation