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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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