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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1146 views
  • 0 likes
  • 3 in conversation