Hello
I am running this simple code and get error: KEY NOT FOUND
What is the problem? How can I fix it?
%let tbl=want2;
%let var=Nr_Increasing_12;
%let TARGET=KESHEL_FUTURE;
PROC SUMMARY DATA=&tbl. (keep= &var. &TARGET.);
VAR &TARGET.;
OUTPUT OUT=inf_klali (DROP=_TYPE_)sum=all_bad;
RUN;
Here is Log
1 The SAS System 19:58 Sunday, November 10, 2024
1 ;*';*";*/;quit;run;
MPRINT(TREND): ;
MPRINT(TREND): *';
MPRINT(TREND): *";
MPRINT(TREND): */;
MPRINT(TREND): quit;
MPRINT(TREND): run;
2 OPTIONS PAGENO=MIN;
MPRINT(TREND): OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
MPRINT(TREND): ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
MPRINT(TREND): OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
MPRINT(TREND): GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
MPRINT(TREND): FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HTMLBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
MPRINT(TREND): ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR STYLE=HTMLBlue
STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css") NOGTITLE NOGFOOTNOTE
GPATH="/usr/local/saswork/SAS_work2B09000039CC_LINX107717A15/SAS_work1A9E000039CC_LINX107717A15/" ENCODING=UTF8 options(rolap="on")
;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24
25 GOPTIONS ACCESSIBLE;
MPRINT(TREND): GOPTIONS ACCESSIBLE;
26 %let tbl=want2;
27 %let var=Nr_Increasing_12;
28 %let TARGET=KESHEL_FUTURE;
29 PROC SUMMARY DATA=&tbl. (keep= &var. &TARGET.);
MPRINT(TREND): PROC SUMMARY DATA=want2 (keep= Nr_Increasing_12 KESHEL_FUTURE);
30 VAR &TARGET.;
MPRINT(TREND): VAR KESHEL_FUTURE;
31 OUTPUT OUT=inf_klali (DROP=_TYPE_)sum=all_bad;
MPRINT(TREND): OUTPUT OUT=inf_klali (DROP=_TYPE_)sum=all_bad;
32 RUN;
MPRINT(TREND): RUN;
ERROR: Key not found.
NOTE: The SAS System stopped processing this step because of errors.
2 The SAS System 19:58 Sunday, November 10, 2024
WARNING: The data set WORK.INF_KLALI may be incomplete. When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.INF_KLALI was not replaced because this step was stopped.
NOTE: PROCEDURE SUMMARY used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.00 seconds
memory 1701.68k
OS Memory 39852.00k
Timestamp 11/10/2024 11:23:32 PM
Step Count 71 Switch Count 0
Page Faults 0
Page Reclaims 239
Page Swaps 0
Voluntary Context Switches 11
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
33
34 GOPTIONS NOACCESSIBLE;
MPRINT(TREND): GOPTIONS NOACCESSIBLE;
35 %LET _CLIENTTASKLABEL=;
36 %LET _CLIENTPROCESSFLOWNAME=;
37 %LET _CLIENTPROJECTPATH=;
38 %LET _CLIENTPROJECTPATHHOST=;
39 %LET _CLIENTPROJECTNAME=;
40 %LET _SASPROGRAMFILE=;
41 %LET _SASPROGRAMFILEHOST=;
42
43 ;*';*";*/;quit;run;
MPRINT(TREND): ;
MPRINT(TREND): *';
MPRINT(TREND): *";
MPRINT(TREND): */;
MPRINT(TREND): quit;
MPRINT(TREND): run;
44 ODS _ALL_ CLOSE;
MPRINT(TREND): ODS _ALL_ CLOSE;
MPRINT(TREND): QUIT;
MPRINT(TREND): RUN;
45
46
47 QUIT; RUN;
48
I would re-start your SAS session. That error doesn't relate to PROC MEANS.
Also you log shows:
MPRINT(TREND):
which suggests that some part of SAS thinks you invoked a macro named TREND. So something very weird is happening.
I would re-start your SAS session. That error doesn't relate to PROC MEANS.
Also you log shows:
MPRINT(TREND):
which suggests that some part of SAS thinks you invoked a macro named TREND. So something very weird is happening.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.