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.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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