Hi all SAS Users,
1. I get something wrong with my logic.
I have the variables cshtrd and prccd_abs_ are numeric variables, the summary is as below
I want to generate a variables named dollar_vol= cshtrd*prccd_abs_
My code is
Comment trading volume*unadjusted price (converted to USD)< 100$
then set missing ;
if cshtrd*prccd_abs_ <100 and n(cshtrd,prccd_abs_)=2
then dollar_vol=.;
else dollar_vol=cshtrd*prccd_abs_;
And the log says that ( I just post lines 37 and 39 because they are relevant to the NOTE)
37 if cshtrd*prccd_abs_ <100 and n(cshtrd,prccd_abs_)=2
38 then dollar_vol=.;
39 else dollar_vol=cshtrd*prccd_abs_;
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
176040 at 37:12 176040 at 39:25
I am wondering what I did wrong in my calculation and is there any hint to fix it?
Warm regards.
The log message:
NOTE: Missing values were generated as a result of performing an operation on missing values
and later it points to log line 37 where the code is:
if cshtrd*prccd_abs_ ....
means that either CSHTRD or PRCCD_ABS or both contain missing value, therefore the result is missing value.
You have to decide if you want to deal with this case in a different way and code your program appropriately.
The log message:
NOTE: Missing values were generated as a result of performing an operation on missing values
and later it points to log line 37 where the code is:
if cshtrd*prccd_abs_ ....
means that either CSHTRD or PRCCD_ABS or both contain missing value, therefore the result is missing value.
You have to decide if you want to deal with this case in a different way and code your program appropriately.
Thank you @Shmuel
After changing to double if, the error note no longer exists, and after checking mean, the results from the old and new code are the same for variable dollar_vol
if n(cshtrd,prccd_abs_)=2 then if cshtrd*prccd_abs_ <100 /*chnaged line*/
then dollar_vol=.;
else dollar_vol=cshtrd*prccd_abs_;
Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: