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
5
votes
1 answer

How come SAS, Proc SQL, doesn't throw an error when I CREATE already existing tables

SAS Beginner here. INTRO: In SQL Server Management Studio an error is thrown when you try to CREATE an object/table that already exists. So the solution is to first DROP the table and then CREATE it. So how come in SAS I can write something like…
frango_mints
  • 59
  • 1
  • 5
5
votes
1 answer

R: Is there an equivalent to SAS's intck function?

I'm moving from SAS to R, and heavily use both INTCK and INTNX. Are there any functions or packages that have similar functionality as these SAS functions? Edit: Specifically I want to be able to compare two dates and return the amount of weeks in…
5
votes
2 answers

SAS program that detects if it runs in SAS base or SAS EG

I'm writing a program that needs different information whether or not in runs in SAS base or SAS EG. Is it possible to write a SAS program that detects whether it is run in SAS EG or SAS base?
Rud Faden
  • 343
  • 2
  • 17
5
votes
2 answers

SAS print ASCII value of special character

I am using the notalnum function in SAS. The input is a db field. Now, the function is returning a value that tells me there is a special character at the end of every string. It is not a space character, because I have used COMPRESS function on the…
Victor
  • 16,609
  • 71
  • 229
  • 409
5
votes
1 answer

How to read large SAS data in R

I have a sas7bdat data set of 2GB which i want to read in R. I am using sas7bdat package to read the dataset but after using read.sas7bdat,there is no response from R and it keeps on running for hours without any output. I have tried using…
Mayur
  • 83
  • 1
  • 8
5
votes
1 answer

Custom color for boxplots in SAS using SGPLOT

The following code comes from SAS's website. I'm using it to ultimately create boxplots, however I have two datasets with same "grouping" variable (with 5 categories/levels/options say A, B, C, D and E). Currently, the code automatically applies…
oivemaria
  • 453
  • 4
  • 20
5
votes
3 answers

User of stored process, which variable to use?

When i look in a SAS log, there are 4 different Variables to grab User: _METAPERSON _METAUSER _SECUREUSERNAME _USERNAME When i check the log, all 4 variables have the same value when i execute the process. So i builded a process which checked…
kl78
  • 1,628
  • 1
  • 16
  • 26
5
votes
3 answers

Use SAS Macro Variable within Proc SQL Teradata passthrough

I have a SQL statement that I wish to automate using SAS EG (9.4). The following statement has been tested in Teradata SQL Assistant and works. select * from TD.DATA where date='2015-06-01' Now I wish to push this through a proc SQL pass through,…
pyll
  • 1,688
  • 1
  • 26
  • 44
5
votes
3 answers

Set in the first row, why do I have two output rows?

I tried this code in SAS but the output isn't the same as I expect. data temp; input sumy; datalines; 36 ; run; data aaa; if _n_ = 1 then set temp; run; proc print data = aaa; run; May I ask why there are two observations, sas…
Darienzhang
  • 51
  • 1
  • 3
5
votes
2 answers

Java exception error during RJDBC::dbConnect: how to silently ignore?

I am trying to connect to a SAS-driven remote database from within R, using RJDBC. The first time I do a dbConnect, I get an error: Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.lang.NoClassDefFoundError:…
Wouter Thielen
  • 1,016
  • 9
  • 21
5
votes
1 answer

Running SAS Enterprise Guide Job on windows Server

I have written a piece of code in SAS EG that simply opens an Excel workbook. The Excel workbook contains VBA code that is executed upon the "Workbook Open" Event. All the code pretty much does, is it refreshes all data connections the first time…
HermannHH
  • 1,732
  • 1
  • 27
  • 57
5
votes
7 answers

Import SAS data file into python data frame

I'm working on a data set (PSID) that gives data in a SAS format (a .txt and another file containing instructions to interpret the data). I cannot find anything in Python to read this type of data. Does anyone know of a pre-existing module/script…
pdevar
  • 323
  • 2
  • 3
  • 11
5
votes
1 answer

macro variable is uninitialized after %let statement in sas

I want to create something in SAS that works like an Excel lookup function. Basically, I set the values for macro variables var1, var2, ... and I want to find their index number according to the ref table. But I get the following messages in the…
Yimai
  • 87
  • 6
5
votes
2 answers

stacking data in SAS

I am trying to rearrange my data but am having a difficult time. The data I have looks something like this: date a b c ==================== 1996 5 7 8 1997 4 2 3 1998 1 9 6 what I want is to rearrange the data…
page1981
  • 51
  • 2
5
votes
2 answers

Performance of SASHELP views versus SQL dictionary tables

Why does it take longer for SAS to create a dataset from a data step view using, for example, sashelp.vcolumn versus the equivalent SQL table dictionary.columns? I did a test using fullstimer and it seems to confirm my suspicion of performance…
Alex A.
  • 5,466
  • 4
  • 26
  • 56