Hi,
I want to cluster the answers of some political parties. My data:
Variable 1: political parties (char)
Variable 2-39: political statement (1=agree, 2=neutral, 3=not agree)
If I perform the Clusteranalysis with centroids-method i got the error: "All variables are constant."
Whats the reason for that?
Thank you for help!
Please look at this data set with your own eyes, to see what is in there. Very likely, the data set was not created properly, and all values are missing. It could also be that all values are constant but not missing.
Thank you for answering. But I didnt get it. I can see the values. Im not sure if these values are constant. I guess not, cause the values within one party are different between the variables. Isnt that the definition?
You show us variables A through J, but you need to look at all variables, perhaps one is all missing.
Please post the complete SAS log that shows the program and the error message.
edit:
@PaigeMiller : actually there is no variable with missing values.
@Ksharp is this true? Cause the name of the political-parties is the group-by-variable and the user-interface of the clusteranalysis means, that format is okay.
By the way, thats the import-code:
data wahlomat;
FORMAT partei $CHAR22.;
input partei a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al
;
datalines;
CDU/CSU 1 3 1 1 2 3 1 1 1 2 1 3 1 1 2 3 3 1 3 1 3 2 3 1 1 2 3 1 3 3 2 2 2 3 3 2 1 3
SPD 3 3 3 1 3 3 3 3 1 3 1 3 1 3 3 3 1 1 1 3 3 1 3 3 1 3 1 3 1 3 3 3 1 3 3 3 3 1
AfD 1 3 1 3 1 3 1 3 3 3 3 3 1 1 1 3 3 1 3 1 3 3 2 1 3 1 1 1 2 3 1 1 1 3 3 1 1 3
FDP 1 3 3 2 1 3 2 1 2 1 1 3 3 2 2 2 3 2 3 3 3 3 3 3 1 1 3 1 1 3 1 3 2 3 3 1 1 2
DIELINKE 3 1 3 1 3 1 3 3 1 3 1 1 3 3 3 2 1 3 1 3 3 1 1 3 1 3 1 3 1 1 3 3 2 1 1 3 3 1
GRÜNE 3 1 3 1 3 1 3 3 1 3 1 1 3 3 3 1 1 3 1 3 3 3 3 3 1 3 3 3 1 2 3 3 3 2 1 3 3 1
FREIEWÄHLER 1 3 1 1 1 3 1 1 1 3 1 2 3 3 2 3 3 2 3 3 3 3 3 3 1 1 1 1 2 3 2 1 1 3 3 2 3 3
DiePARTEI 3 1 3 1 3 1 3 3 1 3 1 1 3 3 3 1 3 3 1 3 3 3 1 3 1 3 1 3 1 3 3 3 3 1 3 3 3 1
Tierschutzpartei 3 1 3 1 3 1 3 3 1 3 1 1 3 3 3 1 1 3 1 3 3 3 1 3 1 2 1 3 1 3 3 3 3 2 1 3 3 1
NPD 1 3 1 3 2 1 1 3 3 3 3 1 3 1 1 3 1 1 3 3 1 3 1 1 3 1 1 1 1 1 3 1 1 2 3 3 3 3
PIRATEN 1 1 3 1 3 1 3 3 1 3 1 3 3 3 2 1 3 2 3 3 3 3 1 3 1 1 1 3 1 3 3 3 3 3 1 3 3 3
DKP 3 1 3 1 3 1 3 3 1 3 1 1 3 3 3 3 3 2 1 3 3 1 1 3 3 1 1 3 1 1 3 2 1 1 1 3 3 1
BüSo 1 1 1 3 3 1 1 2 1 3 3 3 1 1 1 3 3 3 3 1 1 1 3 1 3 1 1 3 1 3 1 3 1 1 1 3 1 3
III.Weg 2 3 1 3 3 1 1 3 3 3 3 2 3 1 1 3 3 1 3 3 1 3 1 1 3 1 2 3 1 1 3 1 1 2 3 3 1 3
TeamTodenhöfer 1 1 2 1 1 1 1 3 1 3 1 3 3 3 1 3 3 3 3 3 3 1 1 3 1 1 1 1 1 3 3 3 1 3 2 1 3 3
Volt 3 1 3 1 3 1 3 3 1 3 1 3 3 3 3 1 3 3 1 3 3 1 1 3 1 3 1 1 1 1 3 3 3 1 1 3 3 3
;
run;
and here´s the log:
1 Das SAS System 07:07 Wednesday, July 6, 2022
8
9 ODS _ALL_ CLOSE;
10 ODS PROCTITLE;
11 OPTIONS DEV=PNG;
12 GOPTIONS XPIXELS=0 YPIXELS=0;
13 FILENAME EGSR TEMP;
14 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
15 STYLE=HtmlBlue
16 STYLESHEET=(URL="file:///C:/xx")
17 NOGTITLE
18 NOGFOOTNOTE
19 GPATH=&sasworklocation
20 ENCODING=UTF8
21 options(rolap="on")
22 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
23
24 GOPTIONS ACCESSIBLE;
25 /* -------------------------------------------------------------------
26 Von SAS-Anwendungsroutine generierter Code
27
28 Generiert am: Mittwoch, 6. Juli 2022 um 07:18:12
29 Von Anwendungsroutine: Clusteranalyse (5)
30
31 Eingabedaten: SASApp:WORK.WAHLOMAT
32 Server: SASApp
33 ------------------------------------------------------------------- */
34 ODS GRAPHICS ON;
35
36 %_eg_conditional_dropds(WORK.SORTTempTableSorted,
37 WORK.CLUSClusterData);
38 /* -------------------------------------------------------------------
39 Bestimmen Sie das Typattribut für den Dateityp (sofern einer definiert wurde),
40 und bereiten Sie es für das Hinzufügen zur Datei/Ansicht vor, die
41 in folgendem Schritt generiert wurde.
42 ------------------------------------------------------------------- */
43 DATA _NULL_;
44 dsid = OPEN("WORK.WAHLOMAT", "I");
45 dstype = ATTRC(DSID, "TYPE");
46 IF TRIM(dstype) = " " THEN
47 DO;
48 CALL SYMPUT("_EG_DSTYPE_", "");
49 CALL SYMPUT("_DSTYPE_VARS_", "");
50 END;
51 ELSE
52 DO;
53 CALL SYMPUT("_EG_DSTYPE_", "(TYPE=""" || TRIM(dstype) || """)");
54 IF VARNUM(dsid, "_NAME_") NE 0 AND VARNUM(dsid, "_TYPE_") NE 0 THEN
55 CALL SYMPUT("_DSTYPE_VARS_", "_TYPE_ _NAME_");
56 ELSE IF VARNUM(dsid, "_TYPE_") NE 0 THEN
57 CALL SYMPUT("_DSTYPE_VARS_", "_TYPE_");
2 Das SAS System 07:07 Wednesday, July 6, 2022
58 ELSE IF VARNUM(dsid, "_NAME_") NE 0 THEN
59 CALL SYMPUT("_DSTYPE_VARS_", "_NAME_");
60 ELSE
61 CALL SYMPUT("_DSTYPE_VARS_", "");
62 END;
63 rc = CLOSE(dsid);
64 STOP;
65 RUN;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
66
67 /* -------------------------------------------------------------------
68 Datei WORK.WAHLOMAT sortieren
69 ------------------------------------------------------------------- */
70 PROC SORT
71 DATA=WORK.WAHLOMAT(KEEP=a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al partei
71 ! &_DSTYPE_VARS_)
72 OUT=WORK.SORTTempTableSorted &_EG_DSTYPE_
73 ;
74 BY partei;
75 RUN;
NOTE: There were 16 observations read from the data set WORK.WAHLOMAT.
NOTE: The data set WORK.SORTTEMPTABLESORTED has 16 observations and 39 variables.
NOTE: PROZEDUR SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
76 TITLE;
77 TITLE1 "Clusteranalyseergebnisse";
78 FOOTNOTE;
79 FOOTNOTE1 "Erzeugt durch das SAS System (&_SASSERVERNAME, &SYSSCPL) am %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) um
79 ! %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";
80
81 PROC CLUSTER DATA=WORK.SORTTempTableSorted
82 METHOD=AVERAGE
83 CCC
84 PSEUDO
85 OUTTREE=WORK.CLUSClusterData(LABEL="Clusterbaumdaten für WORK.WAHLOMAT")
86 PRINT=30
87 PLOTS=PSF
88 PLOTS=PST2
89 PLOTS=CCC
90 ;
91 VAR a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al;
92 BY partei;
93 RUN;
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=AfD
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
3 Das SAS System 07:07 Wednesday, July 6, 2022
partei=BüSo
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=CDU/CSU
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=DIELINKE
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=DKP
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=DiePARTEI
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=FDP
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=FREIEWÄHLER
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=GRÜNE
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=III.Weg
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=NPD
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=PIRATEN
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=SPD
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=TeamTodenhöfer
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=Tierschutzpartei
ERROR: All variables are constant.
NOTE: The above message was for the following BY group:
partei=Volt
NOTE: The data set WORK.CLUSCLUSTERDATA has 0 observations and 55 variables.
NOTE: PROZEDUR CLUSTER used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
94 TITLE;
95 TITLE1 "Baumdiagramm für Clusteranalyse";
96 GOPTIONS HTEXT=0.9 DEVICE=PNG;
NOTE: No units specified for the HTEXT option. The current units associated with GUNIT will be used.
97
98 PROC TREE DATA=WORK.CLUSClusterData
99 ;
100 BY partei;
101 RUN;
4 Das SAS System 07:07 Wednesday, July 6, 2022
NOTE: Keine Beobachtungen in Datei WORK.CLUSCLUSTERDATA.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROZEDUR TREE used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
102 GOPTIONS HTEXT=;
103 /* -------------------------------------------------------------------
104 Ende des Codes für die Anwendungsroutine
105 ------------------------------------------------------------------- */
106 RUN; QUIT;
107 %_eg_conditional_dropds(WORK.SORTTempTableSorted);
NOTE: Table WORK.SORTTEMPTABLESORTED has been dropped.
NOTE: PROZEDUR SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
108 TITLE; FOOTNOTE;
109 ODS GRAPHICS OFF;
110
111
112 GOPTIONS NOACCESSIBLE;
113 %LET _CLIENTTASKLABEL=;
114 %LET _CLIENTPROCESSFLOWNAME=;
115 %LET _CLIENTPROJECTPATH=;
116 %LET _CLIENTPROJECTPATHHOST=;
117 %LET _CLIENTPROJECTNAME=;
118
119 ;*';*";*/;quit;run;
120 ODS _ALL_ CLOSE;
121
122
123 QUIT; RUN;
124
ERROR: All variables are constant. NOTE: The above message was for the following BY group: partei=AfD
Looking at a little more of the log (above), is the problem clear now?
This is why, when there are problems in the log, you need to show us the ENTIRE log for this PROC, not selected parts. (Please consider that showing us the ENTIRE log for a PROC or DATA step is required in your future questions here in the SAS communities)
This is why Maxim 2 "Read the log" was created.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.