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

Generate All Unique Permutations of an Array in SAS

In SAS if I have a string or an Array like the following, array x[4] $1 ('A' 'B' 'C' 'D'); I need to generate all "Unique" permutations of the elements like the…
babsdoc
  • 693
  • 2
  • 11
  • 24
5
votes
2 answers

select specific rows by row number in sas

I am new to SAS I have SAS data like (It does not contain Obs column) Obs ID Name Score1 Score2 Score3 1 101 90 95 98 2 203 78 77 75 3 223 88 67…
Sangram
  • 407
  • 1
  • 6
  • 18
5
votes
3 answers

How to find the length of a numerical variable using PROC SQL

I have a dataset with a column of phone numbers. I want to filter this dataset using PROC SQL WHERE the length of the numbers is at least 7 digits. In normal SQL I can just apply a length function around a number and it works, however in SAS it…
shecode
  • 1,716
  • 6
  • 32
  • 50
5
votes
3 answers

How do I delete tables that all have similar names

I want to use a SAS function such as proc datasets nolist; delete lib.temp_something lib.temp_something2 lib.temp_something3; quit; Is there a shortcut to delete all tables with the same prefix so I dont have to manually type them out?
shecode
  • 1,716
  • 6
  • 32
  • 50
5
votes
1 answer

SAS editor window position

This is not quite a programming question, but SAS programmers might still know an answer: It is possible to make SAS save the settings after shutdown, so the window arrangement will be the same after a restart. We have SAS running on a Server but…
Joz
  • 247
  • 1
  • 3
  • 8
5
votes
1 answer

Hessian in SAS?

Is there any way to get the Hessian matrix in the proc logistic in SAS? Or which will be an option to calculated it taking from departure the proc logsitic? I have been reading the function documentation but cannot see that there is a way to include…
user1571823
  • 394
  • 5
  • 20
5
votes
2 answers

SAS Proc sql row number

How do I get the row number of an observation in proc sql, similar to _N_ for a datastep in proc sql? For example proc sql outobs=5; select case mod(, 2) when 0 then "EVEN" else "ODD" end from…
undershock
  • 754
  • 1
  • 6
  • 26
5
votes
6 answers

how to extract last 4 characters of the string in SAS

improved formatting,I am a bit stuck where I am not able to extract the last 4 characters of the string., when I write :- indikan=substr(Indikation,length(Indikation)-3,4); It is giving invalid argument. how to do this?
user3658367
  • 641
  • 1
  • 14
  • 30
5
votes
2 answers

SAS PROC SQL to join two tables using FULL JOIN

Suppose I have two datasets, --Table 1-- --Table 2-- ID Amount ID Amount1 Code A01 0.1 A01 0.3 x A02 0.2 A02 0.2 y A02 0.3 A03 0.4 g A03 0.4 A03 0.5 u A05 0.6 B01 0.1 …
saspower
  • 53
  • 1
  • 1
  • 4
5
votes
2 answers

Why SAS string concat cannot involve the variable itself?

This issue drives me crazy. In SAS, when I want to concat a string, the variable which will be assigned to the result cannot be used in the input. DATA test1; LENGTH x $20; x = "a"; x = x || "b"; RUN; Result: x = "a"; DATA test2; …
Feng Jiang
  • 1,776
  • 19
  • 25
5
votes
1 answer

Including syntax in SAS ODS pdf file

Is it possible to include submitted syntax or even output of log file when ODS into a PDF using SAS? For instance, give this simple code: ods pdf file = "c:\temp\myPDF.pdf"; proc reg data = mydata; model y = x; run; ods pdf close; I can get the…
Penguin_Knight
  • 1,289
  • 8
  • 13
5
votes
1 answer

Could a D DLL work within SAS?

I've been reading the D Cookbook and near the beginning there's the following sentence: D is binary compatible with C, but not source compatible. SAS allows users to define and call C functions from within SAS. But I'm wondering, would it'd also…
charles
  • 547
  • 1
  • 3
  • 11
5
votes
2 answers

Convert mixed model with repeated measures from SAS to R

I have been trying to convert a repeated measures model from SAS to R, since a collaborator will do the analysis but does not have SAS. We are dealing with 4 groups, 8 to 10 animals per group, and then 5 time points for each animal. The mock data…
Aurélie
  • 75
  • 2
  • 7
5
votes
2 answers

Concatenate quoted macro variables

I'm just trying to concatenate two quoted macro variables but there doesn't seem to be an easy way. Say we have: %LET VAR1="This is not the greatest song in the world"; %LET VAR2="this is just a tribute."; %LET TRIBUTE=%SYSFUNC(CATX(%STR(…
Pane
  • 555
  • 2
  • 7
  • 20
5
votes
2 answers

update with a proc sql

It should be an easy one but I'm stuck Proc sql; UPDATE dicofr SET dicofr.period = correspondance.period FROM dicofr INNER JOIN correspondance ON dicofr.name_fic = correspondance.name_fic; I was thinking my update would be done but I…
Andy K
  • 4,944
  • 10
  • 53
  • 82