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

Which is faster, where statement or where data set option

The question is really straight forward, which one is faster? Considering we are using data step with two datasets in the set statement and the datasets have the same variables in them. From What Ive heard and read, if we subset them using the same…
RamB
  • 428
  • 4
  • 11
6
votes
3 answers

SAS Enterprise Guide customize interface color

Is there any way of changing the background color of SAS Enterprise Guide windows? I have spent more than an hour trying to find a solution, but no success. Unfortunately my eyes cannot take the white background anymore. Thanks in advance!
user3450188
  • 61
  • 1
  • 3
6
votes
1 answer

Is there a way to load rda/RData data from R into SAS?

I have plenty of .rda and .RData files from R statistical packageand would like to read them into SAS. Is there an (easy) way to do this?
Marcin
  • 7,834
  • 8
  • 52
  • 99
6
votes
2 answers

How to import a CSV file with delimiter as ";" and decimal separator as "," into SAS?

I`ve got (and will receive in the future) many CSV files that use the semicolon as delimiter and the comma as decimal separator. So far I could not find out how to import these files into SAS using proc import -- or in any other automated fashion…
Joz
  • 247
  • 1
  • 3
  • 8
6
votes
3 answers

SAS libname odbc, how to access a two-level name table

I recently found the libname statement is very handy to access tables reside in odbc. But I don't know how to access those tables having a two-level names. Below is an example. Old code I use (this code works): proc sql; connect to…
Student222
  • 3,021
  • 2
  • 19
  • 24
6
votes
1 answer

why doesn't %let create a local macro variable?

I always thought that %let creates a local variable if used inside of %macro . . . %mend But when I run this code , the SAS log shows GLOBAL TESTVAR value1 %let testVar = value2; %macro test; %let testVar = value1; %mend; %test %put…
Alex
  • 355
  • 7
  • 25
6
votes
2 answers

SAS . Are variables set to missing at every iteration of a data step?

I always thought that the variables are set to missing for every iteration of the data step . However, in the following code, it looks like the value that the variable gets at the very beginning retains. I can't understand why this happens ? data…
Elvis
  • 255
  • 3
  • 11
6
votes
1 answer

SAS - What is a good way to check if any of the variables in a list is missing

I have datasets where I sometimes need to select observations where none of the variables in the list are missing. i.e I have to do this. Where E1 NE . and E2 NE . and E3 NE . or I can do it little bit more easily like this: Where E1+E2+E3 NE…
Pekka
  • 2,348
  • 2
  • 21
  • 33
6
votes
5 answers

sas one-liner

Is there a way to run a one-liner in sas, or do I have to create a file? I'm looking for something like the -e flag in perl.
David Nehme
  • 21,379
  • 8
  • 78
  • 117
6
votes
2 answers

SAS "successfully assigned from logical server" vs "successfully assigned as follows"

As I was looking through a log file from D:\SAS\XXX\Lev1\SASMain\BatchServer\Logs I saw these two lines NOTE: Libref TESTLIB successfully assigned from logical server. NOTE: Libref TESTLIB was successfully assigned as follows: Engine: …
barney
  • 141
  • 1
  • 2
  • 6
6
votes
3 answers

In SAS, executing a macro without a semicolon?

I am running a macro multiple times in SAS as follows: %mymac(a,b); %mymac(a,c); . %mymac(a,a) %mymac(a,w); . My program/macro is similar to: /* begin program here */ data original_data; set mylib.mydata; run; %macro mymac(x,y); data…
user27008
  • 600
  • 3
  • 15
  • 24
6
votes
1 answer

convert datetime to date in proc-sql sas

I'm trying to convert datetime22.3 variable to ddmmmyy10. in proc sql, this is giving me ****** in the output column. How can I get the correct values in the output column?
staq
  • 163
  • 3
  • 3
  • 11
6
votes
3 answers

Dynamically call macro from sas data step

This code executes fine when Run as a SAS program: %MyMacro(foo_val, bar_val, bat_val); I have created a table using: DATA analyses; input title : $32. weight : $32. response : $32.; datalines; foo1 bar1 bat1 foo2 bar2 bat2 ; I want to…
JustinJDavies
  • 2,663
  • 4
  • 30
  • 52
6
votes
2 answers

How do I save a TextEdit (mac) file with a custom extension (.sas)?

So, I'm in the process of writing some code for SAS and I realized I have to save the file as filename.sas. My professor mentioned that I would have to use note pad or another text editor on my computer. How can I use TextEdit on the Mac to save a…
user24872
  • 99
  • 2
  • 2
  • 5
6
votes
2 answers

Kaplan Meier Survival curve results differ between R and SAS?

I'm re-running Kaplan-Meier Survival Curves from previously published data, using the exact data set used in the publication (Charpentier et al. 2008 - Inbreeding depression in ring-tailed lemurs (Lemur catta): genetic diversity predicts parasitism,…