Thanks to RW9 I upload my sasdata and what I want in excel I just use 150 stocks as the sample tmp0.sas7bdat is original data TMP0.xlsm is I want to get in SAS and I clarify what I demand I will use excel to explain Column J is HoldOn , it is a Boolean Variable if In1=1 then I use next rawdata Open Price as EnterPrice so in the sample, row 15 has a signal and I enter to market at row16. Column K is Serial Number, it is "Num" I used it is nothing within this question, so you can ignore this column Column L is EnterPrice, I've explained above. Column N is out2, it is the problem why I don't use "retian" in SAS to create HoldOn if rawdata's LowPrice smaller than EnterPrice*0.9, then I need to stop my loss. And I need to mark out2=1, just like row 136. In SAS, if I use Variable "In" and Variable "out1" to control "HoldOn", I would hold E1101 from row 135 to row 249, and there would have the same EnterPrice. Actually, I held E1101 from row 135 and sell them at row 136; I held another Serial Number Trade from row 218 to row 244. The two Serial Number Trade have different EnterPrice, so if I nee to use "retain" to create "HoldOn", I think I don't have any idea to code. Column M is OutPrice, if I use out1 to sell my stock I've held, the OutPrice is ClosePrice; if I use out2 to sell it, the OutPrice is LowPrice. Column O is Returns, which calculate I loss or gain in one trade. My question is : Is SAS can create a Boolean variable like VBA which can change inner value at one time running? Thank you!! P.S. Open the Excel, you can push Alt+F11 to open VBA Editor. tmp0.sas7bdat has 4.9mb, system not let me upload... I use google drive https://drive.google.com/drive/folders/0BydLJN40NoEESlgtenZZcXRFbEE?usp=sharing
... View more