BookmarkSubscribeRSS Feed
tjonas
Calcite | Level 5
I have a table with the same field names but some of the data is from 2010 and some from 2009. How do I pull just the 2010 data into a new table?
8 REPLIES 8
DanielKaiser
Pyrite | Level 9
Have you tried the PROC SQL with a WHERE Statement?
tjonas
Calcite | Level 5
I'm a new sas user. Not sure how to use the sql.
DanielKaiser
Pyrite | Level 9
Ok. Have a look at this.

http://www2.sas.com/proceedings/sugi27/p191-27.pdf

If it doesnt help come back and we will go on 🙂
DanielKaiser
Pyrite | Level 9
PROC SQL;
CREATE TABLE DESTINATION.TABLE AS
SELECT * /* Take all Variables from your source table otherwise you can list all var. you want to take */
FROM SOURCE.TABLE
WHERE YEARVARIABLE = 2010;
QUIT;


Hope this works. Haven't worked with SQL so much.
tjonas
Calcite | Level 5
Has this error:
ERROR: Expression using equals (=) has components that are of different data types
DanielKaiser
Pyrite | Level 9
Hm. write 2010 like this '2010' ?

Sry. Not really good english 😄
tjonas
Calcite | Level 5
Work. thanks.
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Hjonas,

Try this:
[pre]
data r;
set i;
where YEAR(date)=2010;
run;
[/pre]
If it will not help give us and example of your data.
Sincerely,
SPR

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2203 views
  • 0 likes
  • 3 in conversation