Hello,
I would like to create a new variable T_heure (Hour slice)
These are examples of my trying. I've tried with and without quotations marks. But I keep getting errors.
if 07:30<=NHeure<=08:15 then T_Heure='07:30-08:15';
if 08:30<=NHeure<=09:15 then T_Heure='08:30-09:15';
if 09:30<=NHeure<=10:15 then T_Heure='09:30-10:15';
.
.
.
if NHeure=>16:30 then T_Heure='16:30+';
if Nheure in (07:30,08:15) then T_Heure=1;
else if Nheure in(08:30, 09:15) then T_Heure=2;
else if Nheure in(09:30, 10:15) then T_Heure=3;
else if Nheure in(10:30, 11:15) then T_Heure=4;
.
.
.
else if Nheure in (16:30) then T_Heure=10;
select (Nheure);
when ("07:30", "07:45", "08:00", "08:15") T_Heure=0;
when ("08:30", "08:45", "09:00", "09:15") T_Heure=1;
when ("09:30", "09:45", "10:00", "10:15") T_Heure=2;
.
.
.
when ("16:30") T_Heure=9;
otherwise T_Heure="";
end; h1=1 if Nheure is (07:30 to 08:15); h1=2 if Nheure is (08:30 to 09:15); h1=3 if Nheure is (09:30 to 10:15); h1=4 if Nheure is (10:30 to 11:15); h1=5 if Nheure is (11:30 to 12:15); Examples of errors: 1068 if 07:30<=NHeure<=08:15 then T_Heure='07:30-08:15'; - 22 76 1069 if 08:30<=NHeure<=09:15 then T_Heure='08:30-09:15'; - 22 76
ERROR 22-322: Syntax error, expecting one of the following: <, <=, =, >, >=, EQ, GE, GT, LE, LT, NE, NG, NL, ^=, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
1164 h1=1 if Nheure is (07:30 to 08:15); -- 388 76 1165 h1=2 if Nheure is (08:30 to 09:15); -- 388 76
per hour or per 2hour.
I've tried different ways with if and select fonction but I couldn't make it work. Could someone help me please. I'm really new to SAS and my data tables are too complicated to manipulate.
My variable NHeure is (in SAS time format):
07:30 07:45 08:00 08:15 08:45 09:00
.
.
.
16:30
... View more