Desktop productivity for business analysts and programmers

SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

Hi everybody,

although a similar question was on this community. I get similar problems with this code:

 

-----8<--------------

DATA Temp;
infile datalines delimiter=',';
format ITEM1 $40. ITEM2 $38.;
INPUT ITEM1 $ ITEM2 $;
datalines;
1000,A
2000,B
3000,C
;
run;

data test;
set Temp;
select (_N_);
when (1) put 'First!';
otherwise put 'Not first!';
run;

----->8--------------

 

The logfile is as follows:

----------8<------------

 

1 The SAS System 21:57 Thursday, January 14, 2016

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='SELECT_OTHERWISE1';
4 %LET _CLIENTPROJECTPATH='F:\8_SAS_Wiki\31_SAS_Syntax_Beispiele\SAS_Syntax.egp';
5 %LET _CLIENTPROJECTNAME='SAS_Syntax.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/6.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 DATA Temp;
24 infile datalines delimiter=',';
25 format ITEM1 $40. ITEM2 $38.;
26 INPUT ITEM1 $ ITEM2 $;
27 datalines;

NOTE: The data set WORK.TEMP has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

31 ;

32 run;
33
34 data test;
35 set Temp;
36 put _N_;
37 select (_N_);
38 when (1) put 'First!';
39 otherwise put 'Not first!';
40 run;

40 run;
_
117
ERROR 117-185: There was 1 unclosed SELECT block.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 2 variables.
WARNING: Data set WORK.TEST was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

2 The SAS System 21:57 Thursday, January 14, 2016


41
42
43 GOPTIONS NOACCESSIBLE;
44 %LET _CLIENTTASKLABEL=;
45 %LET _CLIENTPROJECTPATH=;
46 %LET _CLIENTPROJECTNAME=;
47 %LET _SASPROGRAMFILE=;
48
49 ;*';*";*/;quit;run;
50 ODS _ALL_ CLOSE;
51
52
53 QUIT; RUN;
54

----------8<------------

 

What is going wrong?

 

Best regards

wmueller

 

 


Accepted Solutions
Solution
‎01-14-2016 04:37 PM
Super User
Posts: 5,382

Re: SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

end;?

Data never sleeps

View solution in original post


All Replies
Solution
‎01-14-2016 04:37 PM
Super User
Posts: 5,382

Re: SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

end;?

Data never sleeps
Occasional Contributor
Posts: 15

Re: SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

Ooops. So simple and elegant. Pardon me.

 

 

Community Manager
Posts: 2,887

Re: SELECT WHEN OTHERWISE STATEMENT SAS9.4, EG6.2

@LinusH is correct.  Specifically:

 

DATA Temp;
    infile datalines delimiter=',';
    format ITEM1 $40. ITEM2 $38.;
    INPUT ITEM1 $ ITEM2 $;
    datalines;
1000,A
2000,B
3000,C
;
run;

data test;
    set Temp;
    select (_N_);
        when (1) put 'First!';
        otherwise put 'Not first!';
    end; /* THIS end was missing */
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 395 views
  • 3 likes
  • 3 in conversation