BookmarkSubscribeRSS Feed
jaliu
Quartz | Level 8

jaliu_0-1629924427082.png

in the first line why do we list the three tables first? 

if we don't list them, why doesn't the output statement create the tables as they do when we use output statement elsewhere?

why is there no equal sign after output?

lastly why do we need ; before output sometimes but other times don't?

 

how can i can make sense of these things?

2 REPLIES 2
Reeza
Super User

@jaliu wrote:

 

in the first line why do we list the three tables first? 

 

 


To declare these as output tables. This is the required syntax within a Data step.

 


if we don't list them, why doesn't the output statement create the tables as they do when we use output statement elsewhere?

 


I believe you're referring to the OUTPUT statement in PROCS which have an OUT= option that allows you to then specify the data set name. The OUTPUT statement functions different in a data step (compared to a proc) where you are not required to specify the output data set name, but can specify the output data set name. If you have multiple data sets specified in the DATA statement but do not specify the data set in the OUTPUT statement, it is written to all datasets.

 


why is there no equal sign after output?

 


Because that is the data step syntax for a data set OUTPUT statement. 

I think you may be confusing some of the OUT= options in other procs with the OUTPUT statement. Even with PROC MEANS which has an OUTPUT statement, there's an OUT= to specify the data set name. 

 


lastly why do we need ; before output sometimes but other times don't?

 


 Not sure this is true or correct. Please expand further with examples.

 

how can i can make sense of these things?


Read the documentation very, very closely. 

You seem to be confusing options and statements at the moment for starters. 

 

Please post code as text in the future, and please put a descriptive subject line. This post has nothing to do with IF/THEN DO statements so if someone now searches for help with an IF/THEN question this comes up and is not helpful. 

 


@jaliu wrote:

jaliu_0-1629924427082.png

in the first line why do we list the three tables first? 

if we don't list them, why doesn't the output statement create the tables as they do when we use output statement elsewhere?

why is there no equal sign after output?

lastly why do we need ; before output sometimes but other times don't?

 

how can i can make sense of these things?


 

mkeintz
PROC Star

You can also distribute output observations to multiple datasets without explicit output statements.  You could use "where" flters in the data statement:

 

data indian   (where=(oceancode='I'))
     atlantic (where=(oceancode='A'))
     pacific  (where=(oceancode not in ('A','I')) ;
  set og1.strom_summary;
  length ocean $8;
  keep basic season name maxwindmph ocean;
  basin=upcase(basin);
  oceancode=substr(basin,2,1);
  if ocenacode="I' then ocean="Indian";
  else if oceancode="A" then ocean="Atlantic";
  else ocean="Pacific";
run;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3451 views
  • 4 likes
  • 3 in conversation