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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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
  • 1053 views
  • 1 like
  • 3 in conversation