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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User
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

4 REPLIES 4
Quentin
Super User
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.
thummala
Obsidian | Level 7
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?
Quentin
Super User
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.
Tom
Super User Tom
Super User

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.

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
  • 4 replies
  • 1692 views
  • 2 likes
  • 3 in conversation