## 1 Unclosed Select Block

Solved
Frequent Contributor
Posts: 121

# 1 Unclosed Select Block

```Libname Learn'/folders/myfolders/SASData' ;

Data Sales(keep = Date Amount) Inventory(keep = Partnumber Quantity) ;
Input @16 Code 2. @ ;
If Code eq 1 then do ;
Out = Sales ;
input @1 Date mmddyy10.
@12 Amount 4.  ;
format Date mmddyy10. ;
end ;

Else if Code ne 1 then do ;
Out = Inventory ;
input @1 PartNumber \$ 6.
@8 Quantity 3. ;
end ;
run ;

Data Sales_Only ;
Set Sales ;
Select ;
When (Missing(Date)) New = 1 ;
When (Not Missing(Date)) New = 2 ;
When (Missing(Amount)) New = 3 ;
When (Not Missing(Amount)) New = 4 ;
Otherwise ;
run ; ```

Not sure where this is unclosed? Tx.

Accepted Solutions
Solution
‎04-14-2018 01:21 AM
PROC Star
Posts: 1,351

## Re: 1 Unclosed Select Block

I think you missed an END

```Data Sales_Only ;
Set Sales ;
Select ;
When (Missing(Date)) New = 1 ;
When (Not Missing(Date)) New = 2 ;
When (Missing(Amount)) New = 3 ;
When (Not Missing(Amount)) New = 4 ;
Otherwise ; end;
run ; ```

All Replies
Solution
‎04-14-2018 01:21 AM
PROC Star
Posts: 1,351

## Re: 1 Unclosed Select Block

I think you missed an END

```Data Sales_Only ;
Set Sales ;
Select ;
When (Missing(Date)) New = 1 ;
When (Not Missing(Date)) New = 2 ;
When (Missing(Amount)) New = 3 ;
When (Not Missing(Amount)) New = 4 ;
Otherwise ; end;
run ; ```
Super User
Posts: 9,611

## Re: 1 Unclosed Select Block

http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.3&docsetId=lestmtsref&docsetTarget=p0...

SAS 9.4 and Viya 3.3 Programming Documentation - Data Step Programming - Data Step Statements - Dictionary of D. S. Statements

The presence of the necessary end; statement is prominent in the syntax section.

There is a very strong reason why Maxim 1 is actually the first.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 9,611

## Re: 1 Unclosed Select Block

And you should start writing code in a visually ordered style:

``````Data Sales_Only ;
Set Sales ;
Select ;
When (Missing(Date)) New = 1 ;
When (Not Missing(Date)) New = 2 ;
When (Missing(Amount)) New = 3 ;
When (Not Missing(Amount)) New = 4 ;
Otherwise ;
end;
run ; ``````
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.