BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
serakuru1989
Calcite | Level 5

Data Energyconsm;
if Windows="N" then do; New Windows=1; OldWindows=0;
if Windows="O" then do; Old Windows=1; NewWindows=0;
input Hotel Area NumRooms OccRate EffRooms Windows Energy;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729

4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
Proc print data=Energyconsm;
run;

 

I am not getting an output i require. 

Showing - ERROR 180-322: Statement is not valid or it is used out of proper order. Please Help

 
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Corrected:

 

Data Energyconsm;
input Hotel Area NumRooms OccRate EffRooms  Windows $ Energy;
if Windows="N" then do; NewWindows=1; OldWindows=0;end;
else if Windows="O" then do; OldWindows=1; NewWindows=0;end;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729
4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
;
Proc print data=Energyconsm;
run;

View solution in original post

8 REPLIES 8
novinosrin
Tourmaline | Level 20

Corrected:

 

Data Energyconsm;
input Hotel Area NumRooms OccRate EffRooms  Windows $ Energy;
if Windows="N" then do; NewWindows=1; OldWindows=0;end;
else if Windows="O" then do; OldWindows=1; NewWindows=0;end;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729
4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
;
Proc print data=Energyconsm;
run;
serakuru1989
Calcite | Level 5
Thanks a lot!!
serakuru1989
Calcite | Level 5

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 Data Energyconsm;
72 input Hotel Area NumRooms OccRate EffRooms Windows $ Energy;
73 if Windows="N" then do; New Windows=1; Old Windows=0; end;
___ ___
180 180
ERROR 180-322: Statement is not valid or it is used out of proper order.

74 else if Windows="O" then do; OldWindows=1; NewWindows=0; end;
75 Datalines;

Data is printing but I am still getting error.

novinosrin
Tourmaline | Level 20

show us the code, log you ran plz

serakuru1989
Calcite | Level 5

Data Energyconsm;
input Hotel Area NumRooms OccRate EffRooms Windows $ Energy;
if Windows="N" then do; New Windows=1; Old Windows=0; end;
else if Windows="O" then do; OldWindows=1; NewWindows=0; end;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729
4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
7 45.000 325 49.00 159.25 N 9.766150
8 28.548 199 52.27 104.02 N 3.605958
9 32.865 359 50.00 179.50 N 3.335242
10 59.406 503 57.66 290.03 N 12.928614
11 45.000 416 94.08 391.37 O 8.226040
12 37.435 418 68.70 287.17 N 6.067471
13 50.828 347 49.00 170.03 N 7.233905
14 68.000 455 64.20 292.11 O 11.043565
15 78.868 511 63.51 324.54 N 10.288695
16 28.454 219 76.54 167.62 O 3.662090
17 70.000 501 67.57 338.53 N 11.949033
18 20.000 197 66.00 130.02 N 0.659653
19 50.000 318 61.50 195.57 O 10.034180
;
Proc print data=Energyconsm;
run;

novinosrin
Tourmaline | Level 20
Data Energyconsm;
input Hotel Area NumRooms OccRate EffRooms Windows $ Energy;
if Windows="N" then do; NewWindows=1; OldWindows=0; end;/*notice the correction here plz in varnames*/
else if Windows="O" then do; OldWindows=1; NewWindows=0; end;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729
4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
7 45.000 325 49.00 159.25 N 9.766150
8 28.548 199 52.27 104.02 N 3.605958
9 32.865 359 50.00 179.50 N 3.335242
10 59.406 503 57.66 290.03 N 12.928614
11 45.000 416 94.08 391.37 O 8.226040
12 37.435 418 68.70 287.17 N 6.067471
13 50.828 347 49.00 170.03 N 7.233905
14 68.000 455 64.20 292.11 O 11.043565
15 78.868 511 63.51 324.54 N 10.288695
16 28.454 219 76.54 167.62 O 3.662090
17 70.000 501 67.57 338.53 N 11.949033
18 20.000 197 66.00 130.02 N 0.659653
19 50.000 318 61.50 195.57 O 10.034180
;
Proc print data=Energyconsm;
run;

 

Please review when you copy paste from the forum word by word so you don't make any mistakes 

serakuru1989
Calcite | Level 5

You are a life saver.Thanks a lot!!

I am doing this first time in my life and taking so much time to get an output without error.

Reeza
Super User

There's usually a line number attached to the error. What line is it indicating?

 

Your INPUT is incorrect though - how do you specify a character variable when reading in data?

 


@serakuru1989 wrote:

Data Energyconsm;
if Windows="N" then do; New Windows=1; OldWindows=0;
if Windows="O" then do; Old Windows=1; NewWindows=0;
input Hotel Area NumRooms OccRate EffRooms Windows Energy;
Datalines;
1 43.000 420 32.60 136.92 N 8.199053
2 19.979 215 63.00 135.45 O 6.650887
3 46.529 273 65.05 177.59 O 7.765729

4 20.962 222 70.50 156.51 N 0.446270
5 24.212 474 69.70 330.38 N 2.985187
6 82.200 787 48.97 385.39 O 16.391854
Proc print data=Energyconsm;
run;

 

I am not getting an output i require. 

Showing - ERROR 180-322: Statement is not valid or it is used out of proper order. Please Help

 

 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 8 replies
  • 3495 views
  • 0 likes
  • 3 in conversation