BookmarkSubscribeRSS Feed
Proglegs
Calcite | Level 5

Syntax error.  My SAS code for EMPLID's all start with a zero, for example - 02472.   My code and error is as follows: 

Proglegs_0-1723470993021.png

I am new at SAS so please forgive.  Help!

 

4 REPLIES 4
ballardw
Super User

Please do not post pictures of code or log entries. Copy the text from the editor or log window and on the forum open a text box using the </> icon that appears above the message window and paste the text there. For any question regarding errors in code please post the entire procedure or data step as well. Sometimes depending on what you have actually submitted SAS will not detect some sorts of logic or missing semicolon problems until later in the code when something else is encountered.

 

The text box is important to preserve formatting as text pasted into message windows on this forum will be reformatted and might hide the actual problem. Also for code related questions if we have to completely retype significant portions of your code instead of copy/paste/ edit to make a small change it is less likely to occur.

 

 

I am guessing that you are running proc import. Proc Import does not support an option on the proc statement with where.

You can provide a data set option with a where clause but that would appear immediately after the name of the output data set, would be in parantheses and as data set option appears as (where=(condition goes here) ); So would look something like

out= work.whaterverthatnameis (where=(condition) )

An example of too lazy to retype your entire code right there because I can't copy the data set name from a picture and the way the forum renders them the text in the picture is next to impossible to read when responding.

 

Caution: you are assuming that you know what type of variable will be created and it's name. That sometimes is not a good bet with Proc Import. Also you have the condition as "> '0' " apparently.  Which indicates to me that the variable may well be rendered as numeric by Proc Import. Also there are some tricky things that come in when using > or < comparisons and character values. '9' is "greater than" '1111111' for example because character comparisons are done position by position and if the first position comparison returns true or false for the comparison then SAS stops. So the '9' would likely only be compared to the first '1'.

 

If you actually want "not missing" and your data would have blank values then the condition that you want would be (where=(not missing(emplid)) . The SAS function MISSING will work with either numeric or character values and returns 1/0 (true/false) if the value is missing.

PaigeMiller
Diamond | Level 26

Show us the entire log for this PROC (not portions of the log for this PROC). Provide the log by copying as text and pasting the text into the window that appears when you click on the </> icon.

 

PaigeMiller_0-1715196634946.png

--
Paige Miller
Tom
Super User Tom
Super User

If you are trying to code a WHERE statement you cannot embed it in the middle of another statement.

andreas_lds
Jade | Level 19

If EMPLID has only digits proc import will - most likely - convert it to numeric.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 5993 views
  • 1 like
  • 5 in conversation