Hello.
I want to use an IF-THEN statement followed by a By statement to create a new variable with a selected date given my IF-THEN statement. It seemed to select my conditions and create a new variable. However, when I do a proc print; the date I selected and my new column returns as a " . " instead of the date it originally had.
How can I fix this? is this a formatting issue? I did do a proc contents and both the old and new date variable are NUM so I'm kind of confused on the issue.
Below is my code and my output.
data compare;
set combined;
if Pending='YES' then new_date_num = old_date_num;
by name;
run;
name | old_date_num | date | Pending | new_date_num |
FM1 | 23264 | 9/11/2023 | NO | . |
FM1 | 23264 | 9/11/2023 | NO | . |
FM1 | 23264 | 9/11/2023 | NO | . |
FM1 | 23264 | 9/11/2023 | NO | . |
FM1 | 23271 | 9/18/2023 | NO | . |
FM1 | . | 9/11/2023 | YES | . |
Hi,
Your code seems to return a valid value which is missing when pending='yes';
I want to use an IF-THEN statement followed by a By statement
That does not make any sense. BY statement follow SET/MERGE/UPDATE statements in a DATA step. Or follow the PROC statement in a PROC step.
Since for the observations where Pending='YES' have a missing value of old_date_num where do you want to get a non-missing value for new_date_num ?
Do you want to remember one of the values of new_date_num from one of the previous observations?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.