Why Variable value retaining???

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Why Variable value retaining???

Can some one please help me in identifying the issue here. When my if condition is true the value is being retained. Any input is helpful. Please find the attached files.

 

data test(keep= aeacnno aeshosp aesdisab _aescong _aeshosp _aesdisab);
set AE_shell ae;
if aeacnno eq 1 then _aescong= 'Y';
if aeshosp eq 1 then _aeshosp= 'Y';
if aesdisab eq 1 then _aesdisab= 'Y';
run;

 

 

Thank You.

Attachment

Accepted Solutions
Solution
‎12-20-2015 10:56 AM
Trusted Advisor
Posts: 1,216

Re: Why Variable value retaining???

You could add call missing(_aescong, _aehosp, _aedisab) before your SET statement. This will set the values to null at the start of each iteration of the DATA step.

View solution in original post


All Replies
Trusted Advisor
Posts: 1,216

Re: Why Variable value retaining???

I assume the variables _aescong _aeshosp and _adsdisab exist in either work.AE_shell or work.ae? Variables that are read in on a SET statement are automatically retained.
Occasional Contributor
Posts: 16

Re: Why Variable value retaining???

Yes, that is true. _aescong _aehosp _aedisab variables exist in ae_shell and my requirement is to populate the values based on the conditional statements.
In general ae_shell is an empty dataset(just shell to assign variable attributes). the other dataset(ae) has observations. Any option to work it around in the same step?
Solution
‎12-20-2015 10:56 AM
Trusted Advisor
Posts: 1,216

Re: Why Variable value retaining???

You could add call missing(_aescong, _aehosp, _aedisab) before your SET statement. This will set the values to null at the start of each iteration of the DATA step.
Super User
Super User
Posts: 6,380

Re: Why Variable value retaining???

Or since it appears you are using the AE_SHELL dataset to set the variable order and attributes add the call missing to end of the step. Just add an OUTPUT statement before the call missing.  Otherwise the reference to those variables in the CALL MISSING statement before the SET statement will make them the first three variables in your dataset.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 342 views
  • 2 likes
  • 3 in conversation