Hi Everyone,
A. Can anyone tell me when we use:
1. Output statement.
2. Out= (procedure option) and,
3. Output Out=
B. Can we use all 3 statements/options in SAS DATA sets?
By SAS DATA SET I mean for example:
data male female;
set demographic;
if gender = 'F' then output female;
if gender = 'M' then output male;
run;
C. Can we use all 3 statements/options in SAS Procedures?
D. 'Output out = ' is a procedure option or a statement?
Please give me some examples also, if possible.
Thanks,
Ramanuj
Hi @Ramanuj_Khatri,
You're probably familiar with other programming languages which have essentially one set of statements, functions etc. SAS (more precisely: the SAS programming language) is different from those languages. There is only little overlap between the DATA step language and language elements used in SAS procedures. Moreover, each procedure has its own syntax. There are similarities between certain procedures, but the list of statements with the same function in multiple (Base SAS) procedures is short.
Therefore, I think, the basic picture to start with is
Natural questions would be "How can I ...?"
The answers to such questions will lead you to syntax elements. When you read about the syntax, e.g., of a particular procedure statement, it is a good idea to quickly look through other syntax elements of the same procedure that may be useful later.
As to your questions:
A1. There is an OUTPUT statement in the DATA step (which writes the current observation to a dataset) and there are OUTPUT statements in many procedures (see this list), but they are completely separate.
A2, A3. As described above, each procedure has its own syntax. Some procedures have statements with an OUT= option to create a dataset containing procedure results.
B. SAS datasets contain data. What you describe is a DATA step containing a SET statement. Only the OUTPUT statement (of the DATA step) is valid here, no procedure syntax.
C. Not all procedures have an OUTPUT statement or statements with an OUT= option (e.g. PROC MEANS: yes, PROC PRINT: no).
D. OUT= in procedures (if existent) is always an option of a statement. For example, in PROC FREQ both the TABLES statement and the OUTPUT statement have an OUT= option.
Hi Everyone,
A. Can anyone tell me when we use:
1. Output statement.
2. Out= (procedure option) and,
3. Output Out=
B. Can we use all 3 statements/options in SAS DATA sets?
By SAS DATA SET I mean for example:
data male female;
set demographic;
if gender = 'F' then output female;
if gender = 'M' then output male;
run;
C. Can we use all 3 statements/options in SAS Procedures?
D. 'Output out = ' is a procedure option or a statement?
Please give me some examples also, if possible.
Thanks,
Ramanuj
Hi @Ramanuj_Khatri please avoid cross-posting. Answering the question is so much harder for a community. Please consider removing one version.
Regards, Jan.
Hi @Ramanuj_Khatri please avoid cross-posting. Answering the question is so much harder for a community. Please consider removing one version.
Regards, Jan.
Hi @Ramanuj_Khatri,
You're probably familiar with other programming languages which have essentially one set of statements, functions etc. SAS (more precisely: the SAS programming language) is different from those languages. There is only little overlap between the DATA step language and language elements used in SAS procedures. Moreover, each procedure has its own syntax. There are similarities between certain procedures, but the list of statements with the same function in multiple (Base SAS) procedures is short.
Therefore, I think, the basic picture to start with is
Natural questions would be "How can I ...?"
The answers to such questions will lead you to syntax elements. When you read about the syntax, e.g., of a particular procedure statement, it is a good idea to quickly look through other syntax elements of the same procedure that may be useful later.
As to your questions:
A1. There is an OUTPUT statement in the DATA step (which writes the current observation to a dataset) and there are OUTPUT statements in many procedures (see this list), but they are completely separate.
A2, A3. As described above, each procedure has its own syntax. Some procedures have statements with an OUT= option to create a dataset containing procedure results.
B. SAS datasets contain data. What you describe is a DATA step containing a SET statement. Only the OUTPUT statement (of the DATA step) is valid here, no procedure syntax.
C. Not all procedures have an OUTPUT statement or statements with an OUT= option (e.g. PROC MEANS: yes, PROC PRINT: no).
D. OUT= in procedures (if existent) is always an option of a statement. For example, in PROC FREQ both the TABLES statement and the OUTPUT statement have an OUT= option.
Hi,
A. Is it true that output statement (without an out= option) is valid only in DATA Steps. If no, then,
please describe me (don't give only names) atleast two examples of sas procedures where no 'out=' option is required after output statement.
However, I know that: If the OUT= (or DATA=) option is omitted, the procedure uses the DATAn convention to name the output data set. So, please don't use proc means, proc summary etc.
And please, ignore this:
B. Can we use all 3 statements/options in SAS DATA sets?
By SAS DATA SET I mean for example:
data male female;
set demographic;
if gender = 'F' then output female;
if gender = 'M' then output male;
run;
And, consider this as: Can we use out= or output out= in DATA steps? If yes, then please give me 1 or 2 examples.
Thanks,
Ramanuj
I can only reiterate that the OUTPUT statement of the DATA step and the OUTPUT statements found in some SAS procedures have little in common except their name. It would be a misconception to think of "the OUTPUT statement" as a language element shared by the DATA step and some SAS procedures. Maybe it would avoid confusion if the OUTPUT statement of the DATA step was rather called "WRITE" or something.
You could go through the long list of SAS procedures which have an OUTPUT statement (linked also in my previous post) and try to find one without an OUT= option, but for what purpose? From the top of my head (but I haven't used every procedure in that list) I guess that each of these OUTPUT statements has an OUT= option. Obviously, the "output" must be written somewhere and an output dataset makes much sense, hence there is a need to specify the dataset name. For consistency, the pertinent option of the OUTPUT statements was named OUT= in many if not all SAS procedures which have an OUTPUT statement.
So, yes, if you encounter a line of SAS code that reads output; or output abc; you're most likely reading a DATA step. (You mentioned the rare exception of the default-named DATAn datasets created by PROC steps yourself.)
The OUTPUT statement of the DATA step does not have any options (SAS 9.4 documentation), in particular no OUT= option.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.