BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

I'm new to proc sql. I want to print the results of proc sql table 

 

can you help me to do that??

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@mona4u wrote:

I want to see all the rows that's match the criteria 


No rows match that criteria so somethings wrong with the criteria or your data. 

 

View solution in original post

14 REPLIES 14
Kurt_Bremser
Super User

A simple select without a create table before it will write the result to the currently open ODS destination.

 

Describe your issue in a more specific manner, and don't forget to post the code you already tried (see https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce).

mona4u
Lapis Lazuli | Level 10

this is the code that's I'm using. I don't see the results in the result viewer it's only print 

The SAS System without a table 

 

proc sql ;
select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;

Kurt_Bremser
Super User

What do you mean by 'it's only print'?

 

When you do

proc sql;
select * from sashelp.class;
quit;

In Enterprise Guide you will see the resulting output in the formats you set in the EG options, in their respective tabs.

In SAS Studio, you see the contents of sashelp.class in the Results tab.

mona4u
Lapis Lazuli | Level 10
I use window and I don't see a table with my code
proc sql ;

select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;
quit;
Reeza
Super User

*Creates a data set named WANT in the work library;

proc sql ;
create table want as
select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;
quit;

 

 

*Prints the output to the current ODS open destinations, ie listing or html;

*note the lack of a create table statement, which I've used strikethrough.

proc sql ;
/*create table want as*/ 
select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;
quit;

 

One of these should be what you're looking for.

 

mona4u
Lapis Lazuli | Level 10

that's the message that I got  

 

9306 proc sql ;
9307 create table want as
9308 select empid, jobcode, salary,
9309 salary*.06 as bonus
9310 from sasuser.payrollmaster
9311 where salary <3200
9312 order by jobcode;
NOTE: Table WORK.WANT created, with 0 rows and 4 columns.

9313 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds

Kurt_Bremser
Super User

@mona4u wrote:

that's the message that I got  

 

9306 proc sql ;
9307 create table want as
9308 select empid, jobcode, salary,
9309 salary*.06 as bonus
9310 from sasuser.payrollmaster
9311 where salary <3200
9312 order by jobcode;
NOTE: Table WORK.WANT created, with 0 rows and 4 columns.

9313 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds


This simply means that no observations in the sasuser.payrollmaster dataset match your where condition.

Inspect your dataset.

mona4u
Lapis Lazuli | Level 10

there is obs bc I checked it by proc print 

Kurt_Bremser
Super User

@mona4u wrote:

there is obs bc I checked it by proc print 


NO.

Quote from your previous post:

9312 order by jobcode;
NOTE: Table WORK.WANT created, with 0 rows and 4 columns.

9313 quit;

Zero means zero, period

mona4u
Lapis Lazuli | Level 10

it is wired I was able to print your table without creating a table but with mine I can't 

Kurt_Bremser
Super User

If you run that:

proc sql ;
create table want as
select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;
quit;

and no rows are selected, then

proc sql ;
select empid, jobcode, salary,
salary*.06 as bonus
from sasuser.payrollmaster
where salary <3200
order by jobcode;
quit;

will create no output (you get an empty results tab).

mona4u
Lapis Lazuli | Level 10

I want to see all the rows that's match the criteria 

Reeza
Super User

@mona4u wrote:

I want to see all the rows that's match the criteria 


No rows match that criteria so somethings wrong with the criteria or your data. 

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 14 replies
  • 1356 views
  • 5 likes
  • 3 in conversation