BookmarkSubscribeRSS Feed
asalunkh
Calcite | Level 5

Hello, I am new to SAS and learning basics at the moment.

I want to do insert values in my table for a particular date frame - say, a week. How should I write this in proc sql using a do loop so I don't have to write 7 similar queries for each date? Thank you!

 

 

3 REPLIES 3
Tom
Super User Tom
Super User

Why would you use SQL?

Why not just write a data step instead?

Kurt_Bremser
Super User

From where do you get the data for the week to be inserted?

How does your existing table look like?

Is the data to be inserted already stored in a similar structure as your base table?

 

By giving us data for our orientation, you enable us to find a proper solution.

Data drives code.

PGStats
Opal | Level 21

There is no iteration construct in SQL syntax. To insert data for a week you can say something like:

 

insert into mainTable
select ...
from otherTable
where date between '01jan2018'd and '07jan2018'd;
PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 749 views
  • 0 likes
  • 4 in conversation