BookmarkSubscribeRSS Feed
shahd
Quartz | Level 8

Hi all,

I wrote the below code to conduct clustering analysis but for the results, I got class seven name as class seven 0.10.1
Could you please advice with this

Thanks

data stock;
   length class $ 27;
   input class &$  IH_High IH_Meduim IH_Low US_SH_High_Low US_SH_High_Meduim US_SH_High_Low FM_Low;
   datalines;


Class Four	1.3	1.3	1.3	1.2	1.2	1.2	0.8
Class Five	28.1	18.1	28.1	26.4	36.4	46.4	54.7
Class Six	2.8	2.8	2.8	5	5	5	7.8
Class Seven	0.1	0.1	0.1	0.1	0.1	0.1	0.1
Class eight	2.9	2.9	2.9	5	5	5	4.5
Class nine	60	70	60	60	50	40	30
Class ten	0.5	0.5	0.5	0.6	0.6	0.6	1.4
Class eleven	2.7	2.7	2.7	1.2	1.2	1.2	0
Class twelve	1.3	1.3	1.3	0.3	0.3	0.3	0
Class thirteen 	0.3	0.3	0.3	0.2	0.2	0.2	0.7

;

proc distance data=stock method=dcorr out=distdcorr;
   var interval(IH_High IH_Meduim IH_Low US_SH_High_Low US_SH_High_Meduim US_SH_High_Low FM_Low);
   id class;
run;

proc print data=distdcorr;
   id class;
   title2 'Distance Matrix for 15 Utility Stocks';
run;
title2;

ods graphics on;

/* compute pseudo statistic versus number of clusters and create plot */
proc cluster data=distdcorr method=ward pseudo plots(only)=(psf dendrogram);
   id class;
run;

/* compute pseudo statistic versus number of clusters and create plot */
proc cluster data=distdcorr method=average pseudo plots(only)=(psf dendrogram);
   id class;
run;
2 REPLIES 2
ballardw
Super User

Try inserting an additional space between the Seven and 0.1

 

When I ran your code there was a single, I believe TAB character. When using LIST input with the & modifier you need to have 2 spaces to indicate the end of a variable.

 

You will have the same issue with Eight as well I think.

shahd
Quartz | Level 8
so how can i solve this issue

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 Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 972 views
  • 0 likes
  • 2 in conversation