BookmarkSubscribeRSS Feed
Kati
Calcite | Level 5

Hi,

 

I need to create dummy variable EVENT, which take value one in trading days 0 and +1, I have a column called window, which present trading days, which values goes -16 through + 16, so when window is 0 and 1, event should get value 1, and otherwise event=0

 

How to do this?

I get error message that statement is not valid or it is used out of proper order.

I use SAS University Edition

 

have tried to do this:

 

event=0,

if window=1 or window=0 then event=1;

 

Thank you,

-beginner

5 REPLIES 5
ed_sas_member
Meteorite | Level 14

HI @Kati 

It seems you have a typo -> the coma should be a semi-colon:

 

event=0, -> event=0;

if window=1 or window=0 then event=1;

Kati
Calcite | Level 5
Well, in actual code it is a ;
Kati
Calcite | Level 5
Seems that I have some other problem as well, can you help with that?
ed_sas_member
Meteorite | Level 14

OK. Could you please share a sample of your data and the full data step code you are using ?

ed_sas_member
Meteorite | Level 14

Here is some code that could answer your question.

Could you please compare your code ?

data have;
	input window;
	datalines;
-16
1
7
0
;
run;

data want;
	set have;
	event = 0;
	if window = 0 or window = 1 then event = 1;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 1205 views
  • 0 likes
  • 2 in conversation