Please help with the following unanswered quesiton. this is more programming quesiton. thank you in advance your help!
follwing the quesiton from the URL,
however I have another silly question.
if delflag=0 then output;
if happen=1 then delflag=1;
in the above two statement,
the lines with delflag=0 have been written to the want dataset and
how does the next if clause still truncate the rest of observations against the same id?
and even leave the first "happen=1" in the dataset?
I am trying to learn this logic. your response is very appreicated.
Hello @Lulus,
Here is what happens with each observation of your example dataset when mohamed_zaki's data step is executed (focusing on the three lines of code starting with "if"):
ID seq happen comment 1 1 0 delflag is set to 0, obs. (incl. delflag) is written to WANT due to OUTPUT statement 1 2 0 delflag is still 0 due to RETAIN, obs. is written to WANT 1 3 1 delflag is still 0, obs. is written to WANT, delflag is set to 1 2 1 0 delflag is set to 0, obs. is written to WANT 2 2 1 delflag is still 0, obs. is written to WANT, delflag is set to 1 2 3 0 delflag is still 1, hence obs. is not written to WANT 2 4 1 delflag is still 1, hence obs. is not written to WANT, delflag is set to 1
Hello @Lulus,
Here is what happens with each observation of your example dataset when mohamed_zaki's data step is executed (focusing on the three lines of code starting with "if"):
ID seq happen comment 1 1 0 delflag is set to 0, obs. (incl. delflag) is written to WANT due to OUTPUT statement 1 2 0 delflag is still 0 due to RETAIN, obs. is written to WANT 1 3 1 delflag is still 0, obs. is written to WANT, delflag is set to 1 2 1 0 delflag is set to 0, obs. is written to WANT 2 2 1 delflag is still 0, obs. is written to WANT, delflag is set to 1 2 3 0 delflag is still 1, hence obs. is not written to WANT 2 4 1 delflag is still 1, hence obs. is not written to WANT, delflag is set to 1
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.