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

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

My97_0-1614934161156.png

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.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

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. 

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

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. 

Phil_NZ
Barite | Level 11

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!

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.

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

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
  • 2 replies
  • 710 views
  • 1 like
  • 2 in conversation