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 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!
Please show the log
@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!
You're right - it works if the variable is in quotes! thanks!
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.