Hi, I want to change all missing values from the year 1982 to 1988 to 0, but I want to keep data from 1980 to 1981 and from 1989 to 1991 unchanged. I just put income variable here but my original data set has 45 variables. I want to apply the change to all the variables. Could anyone please help me?
Please do not post data as an image. To use your data we would have to type it out, which you should really do ahead of time.
There are instructions here on how to post your data.
Your question is a conditional execution.
So your conditions appear to be:
If year Greater than or equal to 1982 and year less than or equal to 1988
If income is missing then set income to 0
Else do nothing
If this is correct you can convert it to code via:
*If year Greater than or equal to 1982 and year less than or equal to 1988;
if year >= 1982 and year <= 1998 then do;
*If income is missing then set income to 0;
if income = . then income=0;
*else do nothing;
end;
To incorporate multiple values you would need an array.
To create an array you need to list all the variables somehow and they need to be the same type.
I would suggest giving the expansion a try yourself and posting back if you have issues:
Here's a tutorial:
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
Please do not post data as an image. To use your data we would have to type it out, which you should really do ahead of time.
There are instructions here on how to post your data.
Your question is a conditional execution.
So your conditions appear to be:
If year Greater than or equal to 1982 and year less than or equal to 1988
If income is missing then set income to 0
Else do nothing
If this is correct you can convert it to code via:
*If year Greater than or equal to 1982 and year less than or equal to 1988;
if year >= 1982 and year <= 1998 then do;
*If income is missing then set income to 0;
if income = . then income=0;
*else do nothing;
end;
To incorporate multiple values you would need an array.
To create an array you need to list all the variables somehow and they need to be the same type.
I would suggest giving the expansion a try yourself and posting back if you have issues:
Here's a tutorial:
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/
Thank you for your help. Regarding my impage upload, I am sorry I did not know the rule. Should I upload a SAS file instead from next time?
Don't upload any files.
In the future use the instructions in the post linked to create a data step so someone can recreate your dataset via a program. This means there's no risk of downloading an infected file.
Thank you for your suggestion. I will do
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.