Hello Team,
I've the following code in my program and it is giving me the below error when I run. Please help. Please note that I'm trying to create a new column by multiplying 0.0085 to the column 10th Feb 2021.
ERROR 180-322: Statement is not valid or it is used out of proper order.
data mynewdata;
set WORK.IMPORT;
10Feb_CAD=10th Feb 2021*0.0085;
run;
@mithqueens wrote:
Hello Team,
I've the following code in my program and it is giving me the below error when I run. Please help. Please note that I'm trying to create a new column by multiplying 0.0085 to the column 10th Feb 2021.
ERROR 180-322: Statement is not valid or it is used out of proper order.
data mynewdata;
set WORK.IMPORT;
10Feb_CAD=10th Feb 2021*0.0085;
run;
When you get an error best practice is to copy the code with the error messages and other notes for the entire data step or procedure from the log. The on the forum as part of your question open a text box using the </> icon and paste the text.
If you look at your log you will see that error message comes with diagnostic characters that underline where SAS found the objectionable syntax element(s).
With that in mind, SAS standard variable names start with either a letter or the underscore character followed by letters, digits or underscores. Your 10Feb_CAD, is not a valid standard SAS variable name. If you have name that looks like that because you allowed Proc Import or similar to create one with the option validvarname=any then what you have is called a "name literal". To use it in code you would have to use "10Feb_cad"n, the quotes and letter n tell SAS that you have a non-standard variable name.
With your code I can't tell if you expect to have date value of 10th Feb 2021 or if that is supposed to be another variable name. If it is a variable name then again you would use "10th Feb 2021"n to reference the variable name.
BTW having data values, such as a date, in the name of a variable often makes for complex and difficult to maintain or modify code.
@mithqueens wrote:
Hello Team,
I've the following code in my program and it is giving me the below error when I run. Please help. Please note that I'm trying to create a new column by multiplying 0.0085 to the column 10th Feb 2021.
ERROR 180-322: Statement is not valid or it is used out of proper order.
data mynewdata;
set WORK.IMPORT;
10Feb_CAD=10th Feb 2021*0.0085;
run;
When you get an error best practice is to copy the code with the error messages and other notes for the entire data step or procedure from the log. The on the forum as part of your question open a text box using the </> icon and paste the text.
If you look at your log you will see that error message comes with diagnostic characters that underline where SAS found the objectionable syntax element(s).
With that in mind, SAS standard variable names start with either a letter or the underscore character followed by letters, digits or underscores. Your 10Feb_CAD, is not a valid standard SAS variable name. If you have name that looks like that because you allowed Proc Import or similar to create one with the option validvarname=any then what you have is called a "name literal". To use it in code you would have to use "10Feb_cad"n, the quotes and letter n tell SAS that you have a non-standard variable name.
With your code I can't tell if you expect to have date value of 10th Feb 2021 or if that is supposed to be another variable name. If it is a variable name then again you would use "10th Feb 2021"n to reference the variable name.
BTW having data values, such as a date, in the name of a variable often makes for complex and difficult to maintain or modify code.
Hi Ballardw,
Thank you so much for that feedback. I was able to resolve the problem. Glad to be part of this community.
What is the name of the variable for the "column" labeled "10th Feb 2021"?
Hi Tom,
Thank you for offering the help. I was able to solve the problem. There's was an issue with how I was trying to name the variable.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.