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
16
votes
2 answers

Are statistical programming languages like R/SAS considered functional or procedural

I still don't understand the difference after reading this So, rather than asking what is the difference between functional vs procedural programming, I thought, maybe a language that I am familiar with can serve as an example. Hence, my…
Victor
  • 16,609
  • 71
  • 229
  • 409
16
votes
1 answer

Transfer Function Models :: Arimax in TSA

I am trying to replicate the model from forecasting with dynamic regression models and I can't match the output in R using the arimax function from the TSA library. I am able to get pretty close to the result with SAS but I want to use R and hoping…
B_Miner
  • 1,840
  • 4
  • 31
  • 66
16
votes
4 answers

Compute rolling sum by id variables, with missing timepoints

I'm trying to learn R and there are a few things I've done for 10+ years in SAS that I cannot quite figure out the best way to do in R. Take this data: id class t count desired -- ----- ---------- ----- ------- 1 A …
ADJ
  • 4,892
  • 10
  • 50
  • 83
16
votes
4 answers

Is there a way to detect when you've reached the last observation in a SAS DATA step?

Is there a way to check how many observations are in a SAS data set at runtime OR to detect when you've reached the last observation in a DATA step? I can't seem to find anything on the web for this seemingly simple problem. Thanks!
chucknelson
  • 2,328
  • 3
  • 24
  • 31
15
votes
6 answers

Dropping a table in SAS

What is the most efficient way to drop a table in SAS? I have a program that loops and drops a large number of tables, and would like to know if there is a performance difference between PROC SQL; and PROC DATASETS; for dropping a single table at a…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
15
votes
5 answers

Finding strings that differ with at most one letter from a given string in SAS with PROC SQL

First some context. I am using proc sql in SAS, and need to fetch all the entries in a data set (with a couple of million entries) that have variable "Name" equal to (let's say) "Massachusetts". Of course, since the data was once manually entered by…
Har
  • 377
  • 2
  • 13
15
votes
5 answers

How to read variable names in a SAS data set?

Are there any statements\functions capable of get the name of variables? Preferrably putting them into a column of another data set, a text field or a macro variable. E.g. - Data set 1 Name age sex Jk 14 F FH 34 M Expected data…
mj023119
  • 675
  • 5
  • 12
  • 19
15
votes
1 answer

Validate output XML with XML Schema (xsd)

I create simple XML file in my SAS program: data _null_; file "C:\persons.xml"; put ""; put ""; put "John"; put "32"; put ""; run; And I have XML…
PierreVanStulov
  • 425
  • 2
  • 11
14
votes
6 answers

In SAS, what is the difference between Proc Means And Proc Summary?

What exactly is the difference between Proc Means and Proc Summary? Many sites state that both these are the same, but unless each has something unique will SAS create it?
Tommy
  • 865
  • 4
  • 11
  • 17
14
votes
5 answers

SAS - How to return a value from a SAS macro?

I would like to return a value from a SAS macro I created but I'm not sure how. The macro computes the number of observations in a dataset. I want the number of observations to be returned. %macro nobs(library_name, table_name); proc sql noprint; …
bambi
  • 364
  • 1
  • 3
  • 12
14
votes
1 answer

Quit vs Run statements in SAS

In SAS, what is the difference between 'quit' and 'run'? statements? I cannot figure out when to use 'quit' and when to use 'run'? For example, why is proc datasets using quit but proc contents using run
Victor
  • 16,609
  • 71
  • 229
  • 409
14
votes
4 answers

In SAS, what does the option "dsd" stand for?

I have a quick question. I am learning SAS and have come across the dsd= option. Does anyone know what this stands for? It might assist in remembering / contextualizing. Thanks.
tumultous_rooster
  • 12,150
  • 32
  • 92
  • 149
14
votes
9 answers

SAS Display Manager commands

The SAS display manager is a comamnd line interface to the SAS system, which remains in Base SAS as a legacy facility. However the online documentation on how to use this facility is sparse at best, and google searches are less than fruitful. A…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
13
votes
1 answer

Can I Promote Notes About Uninitialized Variables to Errors

When SAS encounters an uninitialized variable, it will output a note to the log that looks like this: NOTE: Variable not_in_data is uninitialized. Is it possible to have SAS output that message as a warning or an error instead?
David Locke
  • 17,926
  • 9
  • 33
  • 53
13
votes
5 answers

Python sas7bdat module usage

I have to dump data from SAS datasets. I found a Python module called sas7bdat.py that says it can read SAS .sas7bdat datasets, and I think it would be simpler and more straightforward to do the project in Python rather than SAS due to the other…
at_sea
  • 143
  • 1
  • 1
  • 4