Hello,
Trying to load in data via INFILE and then create a new logical column. However, if my data contains ASCII characters (ex. ">", "-") I'm trying to filter on, I don't think SAS is reading it. For example,
dataset =
(Toyota, 35000, >12)
(Toyota, 40000, 12)
data car;
infile 'file path.csv'
input Car $ Miles Group $;
if Group = >12 then NewColumn = "a";
if Group = 12 then NewColumn "b";
run;
Expectation:
(Toyota, 35000, >12, a)
(Toyota, 40000, 12, b)
Results:
(Toyota, 35000, >12, )
(Toyota, 40000, 12, a)
Can someone help explain this, been reading on character comparisons but not much describes how to handle these operations... Thanks!
When comparing strings you have to enclose values in quotes. Try:
if Group = ">12" then NewColumn = "a";
if Group = "12" then NewColumn "b";
When comparing strings you have to enclose values in quotes. Try:
if Group = ">12" then NewColumn = "a";
if Group = "12" then NewColumn "b";
Read the log. It will point you to the issue noted by @andreas_lds.
I moved the question to the Programming community.
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.