BookmarkSubscribeRSS Feed
Ela_84
Fluorite | Level 6

Hi everyone,

 

I wrote a proc sql create table step and I'm bringing in a field called ED and only want the blank fields and the Insertdate must be today's date. below is my my code but I'm getting errors. 

 

Proc sql; create table ELA as select
 a. *
,b. ED

From ELA_1 a left outer join COLD.Off b on a.Account_number=b.ACCOUNT_NUMBER;
Where ED=('Paying','DA2','HP','NOM') and InsertDate = input('2019-08-21',yymmdd8.) then delete;
quit;

8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

One of the variables in your Where Clause is compared to values that are of a different type. You treat ED as a character variable and InserDate as numeric.

Ela_84
Fluorite | Level 6
So I would need to format the numeric to character then?
andreas_lds
Jade | Level 19

@Ela_84 wrote:
So I would need to format the numeric to character then?

Depends on the type of "InsertDate". You can use proc contents to get an overview of the variable and how they are defined.

Ela_84
Fluorite | Level 6
InsertDate is Character and ED is Character

I'm matching the tables using the accountnumbers which are numeric.

I'm very new to SAS, have no idea how to write a proc contents
Kurt_Bremser
Super User

@Ela_84 wrote:
InsertDate is Character 

 accountnumbers which are numeric.

Just the opposite from what it should be. Dates should be stored as SAS dates (numeric, with a date forma, count of days from 1960-01-01), while accountnumbers, which are never used for calculation, should be stored as character.

 

Start by making your data intelligent, then your coding will become much easier. See Maxim 33.

 

And take heed of Maxim 12. Your code is nigh unreadable because of the ugly, inconsistent non-formatting.

 

And fix ERRORs from the top. Your first ERROR is here

Proc sql; create table ELA as select
 a. *

caused by the blank between the dot and asterisk.

Kurt_Bremser
Super User

@Ela_84 wrote:



I'm very new to SAS, have no idea how to write a proc contents

Very easy. Read the documentation (Maxim 1), and write the code. It's especially easy with proc contents:

proc contents data=/* insert your dataset here */;
run;
Patrick
Opal | Level 21

@Ela_84 wrote:

Hi everyone,

 

I wrote a proc sql create table step and I'm bringing in a field called ED and only want the blank fields and the Insertdate must be today's date. below is my my code but I'm getting errors. 

 

Proc sql; create table ELA as select
 a. *
,b. ED

From ELA_1 a left outer join COLD.Off b on a.Account_number=b.ACCOUNT_NUMBER;
Where ED=('Paying','DA2','HP','NOM') and InsertDate = input('2019-08-21',yymmdd8.) then delete;
quit;


The code you've posted here is not valid SQL. I've made the obviously wrong parts above bold red.

The then delete makes me question what your desired result actually might be so I'm not trying to fix the syntax without further information.

 

The easiest way to help you would be if you also post sample data (like working SAS data steps which create the source tables) and then tell/show us how the desired result should look like.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2985 views
  • 0 likes
  • 5 in conversation