Hello,
I am trying to make a code that can help me recategorize my tables. The variables that will be conditioned are: Province and City. Basically, if Province is = to Toronto and the Province is Ontario, i'd like the region to be categorized as "Toronto". If province is = to Ontario and city is NOT equal to toronto, id like region to be categorized as "outside of toronto".
Here is the code I have:
data work.tester2;
if province="ON" and city="torontp"
then
Region="Toronto";
else if province= "ON" and city^="toronto"
then Region="outside of toronto";
end;
run;
when I run this code, all fields go blank.
Thanks
Ah, you aren't reading any data in. You need a SET statement to read in an existing SAS dataset.
Try removing your END statement and can only be used with a matching DO statement which you don't have.
Check your SAS log for errors. What does it say?
Ah, you aren't reading any data in. You need a SET statement to read in an existing SAS dataset.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.