BookmarkSubscribeRSS Feed
ashmishah
Calcite | Level 5

I am learning sas and totally new to this field. I have 2 doubts:

1.  I have to do hierarchical clustering for a dataset. How can i do hierarchical clustering using 2 dataset out of which one is demographic data and other is survey data.

2. I was trying to write a code to do clustering for survey data. Here is the code:

 

data a1;
 infile "/folders/myfolders/pda.csv" dlm=',' firstobs=2;
 input ID $ Innovator $ Use_message $ Use_cell $ Use_PIM $ Inf_passive $ INF_active $ remote_access $ Share_info $ Monitor $ Email $ Web $ M_media $ ergonomic $ monthly price;
 run;

proc cluster simple noeigen method=centroid rmsstd rsquare nonorm outtree=a2;
id ID Innovator Use_message Use_cell Use_PIM Inf_passive INF_active remote_access Share_info Monitor Email Web M_media ergonomic;
var price monthly;
run;

 

But it is showing this again and again.

proc cluster simple noeigen method=centroid rmsstd rsquare nonorm outtree=a2;
63         id ID Innovator Use_message Use_cell Use_PIM Inf_passive INF_active remote_access Share_info Monitor Email Web M_media
                  _________
                  22
                  76
63       ! ergonomic;
ERROR 22-322: Expecting ;. 
ERROR 76-322: Syntax error, statement will be ignored.
64         var price monthly;
65         run;
 
How can i proceed with it.
 
I am attaching one of the file here.
4 REPLIES 4
Reeza
Super User

Your ID statement is incorrect. 

 

Looking at the documentation, it states that it requires a single variable, not variable(s), and is used to identify a record. It should be unique for each observation. I'm not sure what you're trying to do with this, so can't make suggestions beyond the correction. 

 

ID Statement

  • ID variable;

The values of the ID variable identify observations in the displayed cluster history and in the OUTTREE= data set. If the ID statement is omitted, each observation is denoted by OBn, where n is the observation number.

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_cluster_synt...

ashmishah
Calcite | Level 5

I have to Perform hierarchical cluster analysis on the PDA data. As all the other variables are categorical can i keep it in var statement?

I am attaching the description herewith.

Reeza
Super User

@ashmishah wrote:

I am learning sas and totally new to this field. I have 2 doubts:

1.  I have to do hierarchical clustering for a dataset. How can i do hierarchical clustering using 2 dataset out of which one is demographic data and other is survey data.

2. I was trying to write a code to do clustering for survey data. Here is the code:

 

data a1;
 infile "/folders/myfolders/pda.csv" dlm=',' firstobs=2;
 input ID $ Innovator $ Use_message $ Use_cell $ Use_PIM $ Inf_passive $ INF_active $ remote_access $ Share_info $ Monitor $ Email $ Web $ M_media $ ergonomic $ monthly price;
 run;

proc cluster simple noeigen method=centroid rmsstd rsquare nonorm outtree=a2;
id ID Innovator Use_message Use_cell Use_PIM Inf_passive INF_active remote_access Share_info Monitor Email Web M_media ergonomic;
var price monthly;
run;

 

But it is showing this again and again.

proc cluster simple noeigen method=centroid rmsstd rsquare nonorm outtree=a2;
63         id ID Innovator Use_message Use_cell Use_PIM Inf_passive INF_active remote_access Share_info Monitor Email Web M_media
                  _________
                  22
                  76
63       ! ergonomic;
ERROR 22-322: Expecting ;. 
ERROR 76-322: Syntax error, statement will be ignored.
64         var price monthly;
65         run;
 
How can i proceed with it.
 
I am attaching one of the file here.

I personally have a policy of not answering homework questions. My advice would be to work through the examples in the documentation first or one from your textbook. These should give you enough of a basis to answer your homework questions. 

Ksharp
Super User
I noticed you have some character variables.
proc cluster can not handle the character variables.

Try use PROC DISTANCE to get distance matrix and 
feed it into proc cluster .


sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2218 views
  • 0 likes
  • 3 in conversation