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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.