Questions tagged [sas]

The SAS language is a 4GL that underpins the SAS system, a suite of products centered around data processing and statistical procedures. For questions about code, please include your code and some data to reproduce your problem, either in datalines/cards statements or using a sashelp dataset like sashelp.class or sashelp.cars.

The SAS System is a proprietary suite of products used for business intelligence, data warehousing, data processing, and statistical analysis, across many industries, but particularly pharmaceuticals, finance and telecoms. It is available for (and often acting as a bridge between) mainframe, UNIX, Linux and Windows platforms.

The SAS System is a 4th generation programming environment, in that it includes a fully featured GUI with many user tasks able to be accomplished without coding. The SAS language itself is more powerful than the typical query language available in 4GLs, being more similar to a scripting language such as Python combined with built-in SQL and SQL-type queries.

SAS programs typically consist of two types of steps: data steps and proc steps. A data step creates a new data file or modifies an existing data file. Data steps can also serve to create user reports. Proc steps allow users to analyze data and provide user reports, such as summary statistics, charts of data, and correlations between variables. In addition SAS has ODS for Output in various formats like html, excel and pdf.

SAS also includes a macro language (also found in ) to conditionally control program code and improve readability.

SAS University Edition is an academic and free download for the SAS language available at http://support.sas.com/software/products/university-edition/

Questions about SAS that are on topic are questions about programming in SAS (writing code), questions about interacting with the programming environments related to SAS (Base SAS, Enterprise Guide, SAS Studio), or questions about SAS-related tools that are used in conjunction with programming (such as the prompt interface used in a programming context).

Questions about various SAS visual tools (such as SAS Visual Analytics) that are not used in conjunction with user written code, even if they could be used with writing code, are not on topic, nor is server administration. Please find appropriate communities for those questions, or the SAS community forums for any SAS related question that does not fit well here.


Well written SAS questions will include complete code to reproduce any issue you are having, and data to go with that code. Either use sashelp datasets (sashelp.class or sashelp.cars for example), or input your own data using a datalines statement, like so:

data have;
 input x y z;
 datalines;
1 2 3
4 5 6
7 8 9
;
run;

Examples of good questions that include datalines include How to use Boolean datatype in SAS? and PROC Report, multiple columns with same statistic. Examples of good questions using sashelp datasets include substr function with macro variable name and using where in sas macro when subsetting dataset.


Vendor website

15658 questions
6
votes
3 answers

Any difference between union all corresponding and outer union corresponding?

Could someone verify my understanding of proc sql union operations? My interpretation of the differences between outer union and union is the following: Union deletes duplicate rows, while outer union does not Union will overlay columns, while…
Nate
  • 420
  • 1
  • 5
  • 17
6
votes
2 answers

PROC SQL in SAS - All Pairs of Items

I have a dataset in which I need to look at all pairs of items that are together from within another group. I've created a toy example below to further explain. BUNCH FRUITS 1 apples 1 bananas 1 mangos 2 apples 3 …
pmbaumgartner
  • 672
  • 3
  • 12
6
votes
1 answer

Editing SAS config files to execute R (making SAS play well with others)

There are many things that R just does better. Hence, I am trying to set my system up so I can execute R commands from within SAS using the [submit /R;] and [endsubmit;] commands. However I need some help getting my config files set up properly to…
ESmyth5988
  • 518
  • 2
  • 9
  • 20
6
votes
1 answer

SAS: Hidden retain statement inside set statement?

Consider the following example: /* Create two not too interesting datasets: */ Data ones (keep = A); Do i = 1 to 3; A = 1; output; End; run; Data numbers; Do B = 1 to 5; output; End; Run; /* The interesting step: */ Data together; Set ones…
Vincent
  • 677
  • 2
  • 7
  • 19
6
votes
2 answers

SAS Pass-through SQL - Multiple DBs

I want to retrieve from DB2 the list of records that matches the identifiers in a DB1 table, like a regular SAS subquery. How can I perform that with SAS pass-through SQL? Performing the (long and complex) SQL on db1 is too slow using a regular SAS…
user1839897
  • 425
  • 1
  • 10
  • 14
6
votes
2 answers

transpose efficiently with proc sql

i would like to know if it is possible to transpose efficiently from wide to long using proc sql in sas. I'm aware that proc transpose is much quicker that the method i suggest below. But one of my objective would be to avoid storing the transposed…
DJJ
  • 2,481
  • 2
  • 28
  • 53
6
votes
2 answers

Run SAS from VBA with full access

I hope someone can help. I'm trying to build a subroutine to launch SAS from VBA. I've been doing so with SAS Workspace Manager. As I'm strolling pretty far from my comfort zone I've followed mostly what I found in these two sources. Here's what I…
Pane
  • 555
  • 2
  • 7
  • 20
6
votes
5 answers

Writing Efficient Queries in SAS Using Proc sql with Teradata

EDIT: Here is a more complete set of code that shows exactly what's going on per the answer below. libname output '/data/files/jeff' %let DateStart = '01Jan2013'd; %let DateEnd = '01Jun2013'd; proc sql; CREATE TABLE output.id AS ( SELECT DISTINCT…
Jeffrey Kramer
  • 1,345
  • 6
  • 25
  • 43
6
votes
5 answers

Drop a range of variables in SAS

I currently have a dataset with 200 variables. From those variables, I created 100 new variables. Now I would like to drop the original 200 variables. How can I do that? Slightly better would be, how I can drop variables 3-200 in the new dataset.…
sujinge9
  • 231
  • 3
  • 4
  • 7
6
votes
7 answers

How can I read/convert SAS Gov't Data files on a MAC?

There are gov't data files: http://www.cdc.gov/EpiInfo/ Available in this weird SAS format. How can I convert them into XML/CSV, something much simpler that can be read by scripts/etc.???
MikeN
  • 45,039
  • 49
  • 151
  • 227
6
votes
2 answers

Generating random numbers in SAS

how to generate random integers between 10 and 50 using ranuni() function in sas. For generating random integer between 1 to 5, I used this code data random; do i=1 to 10; random_int = int(ranuni(0) * 5 + 1); output; end; run;
Sanyam Gupta
  • 93
  • 1
  • 1
  • 7
6
votes
6 answers

R equivalent of .first or .last sas operator

Does anybody know what is the best R alternative to SAS first. or last. operators? I did find none. SAS has the FIRST. and LAST. automatic variables, which identify the first and last record amongst a group with the same value with a particular…
Giorgio Spedicato
  • 2,413
  • 3
  • 31
  • 45
6
votes
2 answers

Difference between PROC SQL and sqldf

I am in the midst of re-writing a SAS program I normally use into R. Many statements in the SAS program are written with proc sql, so for ease of programming I am replicating those statements with sqldf in R. All of the sql code works the same with…
user1445246
  • 303
  • 4
  • 14
5
votes
2 answers

Normality Tests in SAS

I'm completely new to SAS and I'm desperate. So, my code is: DATA abc; INPUT AA BB CC DD EE; CARDS; ; RUN; PROC PRINT DATA = abc; TITLE "My_Data"; RUN; PROC UNIVARIATE DATA = abc OUTTABLE = Table NOPRINT; VAR AA BB CC DD EE; …
abc
  • 167
  • 1
  • 4
  • 18
5
votes
2 answers

Stop SAS Program on Error

I am using a macro to stop my SAS program on an error, but it always disconnects from the server and then I cannot get back my temporary data sets anymore. I have tried: OPTIONS ERRORABEND; Here is the macro I have tried: %macro errchk; %if &syserr…
Nick Nelson
  • 1,131
  • 2
  • 18
  • 36