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

Hello,

 

I'm using SAS 9.4. I have a variable that contains both numbers and letters (example below). When I run proc contents, SAS is recognizing it as a character variable. However, when I go to make a new variable from this variable in a data step, I keep getting errors regardless of whether I put quotes around it or not. Any ideas?

 

99.2 Intubation

99.3 Bronchoscopy

99.4 Thoracentesis

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@lmyers2 wrote:

However, when I go to make a new variable from this variable in a data step, I keep getting errors regardless of whether I put quotes around it or not. Any ideas?

 


Your variable name is without quotes but the value must be in quotes and match exactly. 

Post your code and error so we can help you figure out what to change. 

 

if varName in ('99.2 Intubation', '99.3 Bronchoscopy') then category = 1;
else category = 2;

@lmyers2 wrote:

Hello,

 

I'm using SAS 9.4. I have a variable that contains both numbers and letters (example below). When I run proc contents, SAS is recognizing it as a character variable. However, when I go to make a new variable from this variable in a data step, I keep getting errors regardless of whether I put quotes around it or not. Any ideas?

 

99.2 Intubation

99.3 Bronchoscopy

99.4 Thoracentesis

 

Thanks!

 

 


 

View solution in original post

3 REPLIES 3
r_behata
Barite | Level 11

Please show the log

Reeza
Super User

@lmyers2 wrote:

However, when I go to make a new variable from this variable in a data step, I keep getting errors regardless of whether I put quotes around it or not. Any ideas?

 


Your variable name is without quotes but the value must be in quotes and match exactly. 

Post your code and error so we can help you figure out what to change. 

 

if varName in ('99.2 Intubation', '99.3 Bronchoscopy') then category = 1;
else category = 2;

@lmyers2 wrote:

Hello,

 

I'm using SAS 9.4. I have a variable that contains both numbers and letters (example below). When I run proc contents, SAS is recognizing it as a character variable. However, when I go to make a new variable from this variable in a data step, I keep getting errors regardless of whether I put quotes around it or not. Any ideas?

 

99.2 Intubation

99.3 Bronchoscopy

99.4 Thoracentesis

 

Thanks!

 

 


 

lmyers2
Obsidian | Level 7

You're right - it works if the variable is in quotes!  thanks!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 399 views
  • 0 likes
  • 3 in conversation