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
4 answers

How can I use Proc SQL to find all the records that only exist in one table but not the other?

I'm trying to do this in Enterprise Guide, with a task, otherwise I would just use a data step. In a data step, this would be: data names; input name $; datalines; John Mary Sally Fred Paul ; run; data check; input name $; …
Jay Corbett
  • 28,091
  • 21
  • 57
  • 74
5
votes
3 answers

Capture stdout and stderr from SAS in Windows?

I want to call a SAS program from another program on Windows. I have some experience invoking SAS from the command line in batch mode, but no real experience receiving messages from it and handling those messages. I have googled around and found…
oob
  • 1,948
  • 3
  • 26
  • 48
5
votes
5 answers

ODBC Password Security in SAS

We want to remove hardcoded passwords from ODBC connection strings in our SAS code, and also prevent any of the passwords from appearing in the SAS log files. There seems to be plenty of whitepapers discussing how to go about this but I either find…
Robert Penridge
  • 8,424
  • 2
  • 34
  • 55
5
votes
1 answer

Converting mixed model formula from SAS to R

I want to fit a mixed model using nlme package in R which is equivalent to following SAS codes: proc mixed data = one; class var1 var2 year loc rep; model yld = var1 * var2; random loc year(loc) rep*year(loc); EDITS: Explanation of what is…
jon
  • 11,186
  • 19
  • 80
  • 132
5
votes
1 answer

if _N_ = 1 condition returns true even if the set dataset is empty (zero observations) in SAS

A doubt on SAS: data new; set _NULL_; run; data _NULL_; set new; if _N_ = 0 then call execute ("%put empty dataset;"); if _N_ = 1 then call execute ("%put non-empty dataset;"); run; The above bit of…
AP-
  • 57
  • 2
  • 6
5
votes
1 answer

Python - Is there a shorthand for [eg]: print(f'type(var) = {type(var)}')

Is there a shorthand in Python for (e.g.) print(f'type(var) = {type(var)}'), without having to state the object in the text and the {.}? The short answer may be "no", but I had to ask! E.g. in SAS one may use &= to output a macro variable and its…
5
votes
1 answer

submit SAS code or macro from Toolbar

Is it possible to allocate a SAS script or macro to a Toolbar button in Base SAS? ie can you 'dm' a macro or sas script?
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
5
votes
5 answers

SQL Passthrough in SAS

Are there any advantages of using SQL Passthrough facility along with SAS?
Tommy
  • 865
  • 4
  • 11
  • 17
5
votes
4 answers

How can I perform a piece of macro for each observation in sas data step?

Suppose I allow user to write his own variable calculation macro using a common user interface: %macro calculate(var_name, var_value); %* Some user-defined calculation; %mend calculate; Then in a data step, I can calculate a new variable using the…
Steve
  • 4,935
  • 11
  • 56
  • 83
5
votes
1 answer

Reading Oracle data from SAS in a UTF-8 session - characters lose accent

SAS 9.4 M6 on a Unix server. SAS EG 8.1 client. When reading data in SAS from Oracle (10g release 10.2.0.4.0), special characters like "é", "â" are stripped from their accent so we end up with "e", "a". The result is the same whether we use libname…
FrankO
  • 61
  • 4
5
votes
1 answer

For a SAS dataset, what is the best way to prevent locking for multiple user access

Thanks for reading this. I am using a shared service (server=sharedLib) when setting up my libref, to allow users of my SAS/IntrNet application to modify and update (add new) records of a single dataset. The application will also be used to query my…
Jay Corbett
  • 28,091
  • 21
  • 57
  • 74
5
votes
4 answers

Test if a variable exists

I want to test if a variable exists and if it doesn't, create it.
Murray
  • 660
  • 1
  • 8
  • 20
5
votes
3 answers

Avoiding a SAS error message: "NOTE: Invalid argument to function INPUT"

Is there a way to test if a variable will fail the INPUT conversion process in SAS ? Or alternatively, if the resulting "NOTE: Invalid argument" message can be avoided? data _null_; format test2 date9.; input test ; …
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
5
votes
3 answers

Convert numeric into an alphanumeric value based on radix 36

It is easy to transform a number into a alphanumeric value based on radix 16 in SAS by using the $HEX format. Now i'm looking for an easy way to do this with radix 36 (10 numerals & 26 letters). Examples: 100 -> '2s' 2000 -> '1jk' 30000 ->…
TechnoCore
  • 1,394
  • 2
  • 16
  • 21
5
votes
1 answer

adjusting the project.xml file in a SAS Enterprise Guide project outside SAS EG

We are going to migrate our EG projects (over 1000 projects) to a new environment. In the old environment we use "W-Latin" as encoding on the Teradata database. In the new environment we will start using "UTF-8" as encoding on the Teradata…
Aniel
  • 53
  • 5