Hello,
i have done this to find the top ten countries with the highest frequency
%let TopN = 10;
proc freq data=new.resultinterp ORDER=FREQ;
tables A_BirthCountry / maxlevels=&TopN Plots=FreqPlot;
run;
and then I want to put the rest in an "other" category so i started with this data step
data country;
set new.resultinterp;
If A_BirthCountry = not("MYANMAR (BURMA)" or "IRAQ" or "BHUTAN" or "SOMALIA" or "AFGHANISTAN" or "DEMOCRATIC REPUBLIC OF CONGO " or "ETHIOPIA" or "BURMA" or "CUBA" or "ERITREA")
then A_birthcountry = "Other";
run;
please help
but it comes with an error that it is invalid error
See https://blogs.sas.com/content/iml/2018/06/04/top-10-table-bar-chart.html
Also, this line is the error
If A_BirthCountry = not("MYANMAR (BURMA)" or "IRAQ" or "BHUTAN" or "SOMALIA" or "AFGHANISTAN" or "DEMOCRATIC REPUBLIC OF CONGO "
or "ETHIOPIA" or "BURMA" or "CUBA" or "ERITREA")
then A_birthcountry = "Other";
It should say
If A_BirthCountry = not in ("MYANMAR (BURMA)" ,"IRAQ","BHUTAN",
"SOMALIA" ,"AFGHANISTAN","DEMOCRATIC REPUBLIC OF CONGO ",
"ETHIOPIA","BURMA" ,"CUBA","ERITREA") then A_birthcountry = "Other";
Please pay attention to details, not that DEMOCRATIC REPUBLIC OF CONGO has a space after it and before the double-quote, maybe that's not what you want.
From now on, please, when there are ERRORs in the log, then show the ENTIRE log for this DATA step. Do not show us parts of the log, as you have done, we need to see the ENTIRE log for this DATA step. Please do not say "but it comes with an error that it is invalid error" and tell us nothing further, this is non-informative, we need to see the ENTIRE log for this DATA step.
See https://blogs.sas.com/content/iml/2018/06/04/top-10-table-bar-chart.html
Also, this line is the error
If A_BirthCountry = not("MYANMAR (BURMA)" or "IRAQ" or "BHUTAN" or "SOMALIA" or "AFGHANISTAN" or "DEMOCRATIC REPUBLIC OF CONGO "
or "ETHIOPIA" or "BURMA" or "CUBA" or "ERITREA")
then A_birthcountry = "Other";
It should say
If A_BirthCountry = not in ("MYANMAR (BURMA)" ,"IRAQ","BHUTAN",
"SOMALIA" ,"AFGHANISTAN","DEMOCRATIC REPUBLIC OF CONGO ",
"ETHIOPIA","BURMA" ,"CUBA","ERITREA") then A_birthcountry = "Other";
Please pay attention to details, not that DEMOCRATIC REPUBLIC OF CONGO has a space after it and before the double-quote, maybe that's not what you want.
From now on, please, when there are ERRORs in the log, then show the ENTIRE log for this DATA step. Do not show us parts of the log, as you have done, we need to see the ENTIRE log for this DATA step. Please do not say "but it comes with an error that it is invalid error" and tell us nothing further, this is non-informative, we need to see the ENTIRE log for this DATA step.
Thank you for your help and I tried your new code and this is the error I got
We don't know what is on line 71. Show us the ENTIRE log for this DATA step, that's 100% of the log for this DATA step, every single line in the log for this data step. Please copy the log as text and then paste it into the window that appears when you click on the </> icon.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.