BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chee154
Calcite | Level 5

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! 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

When comparing strings you have to enclose values in quotes. Try:

if Group = ">12" then NewColumn = "a";
if Group = "12" then NewColumn "b";

View solution in original post

3 REPLIES 3

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 998 views
  • 1 like
  • 3 in conversation