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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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