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

Running a large oracle SQL script in a loop

I have created a large piece of script which inserts new rows at the very end into my target table. Script contains many select statements and interim tables. I want to loop it to run 2000 times consecutively and can't see any alternative than…
5
votes
1 answer

In Base SAS, how can I auto refresh the explorer?

I'm fairly sure this must be something that has bugged others and so there must be a solution. I write my code and want to quickly check the dataset, but it isn't there. I need to select the window, click View and click refresh. Is there a…
James Oliver
  • 547
  • 1
  • 4
  • 17
5
votes
2 answers

Ixutil commands on SAS spds Cluster tables

Can indexes be reorganized of SAS SPDS Cluster tables? i.e. Can IXUTIL commands be run directly on SAS Cluster tables ( without unclustering first). I tried running on the cluster tables with various alterations but so far only getting errors like:…
in_user
  • 1,948
  • 1
  • 15
  • 22
5
votes
3 answers

How to add leading zeros to character field in SAS?

I trying to figure out the following: I have SAS dataset 'ids' with character variable with different length such as idnum3, idnum897 or idnum2342345. Need to create each ID with the same length and add leading zeros to have soething like…
5
votes
3 answers

how to list all available user defined macros in SAS Enterprise Guide?

Say in my main code I have this code block: %macros hi5; %put hi five; %mend; %macros helloworld; %put hello world; %mend; How do I, in SAS Enterprise Guide, display something like this? (via log or via a SAS table) These are the user defined…
Atlas7
  • 2,726
  • 4
  • 27
  • 36
5
votes
2 answers

How to compute regression coefficients with proc mixed in sas?

Here are my data. Data are structured like so: id x1 x2 x3 y. I used proc mixed to analyze it, but now want to determine regression coefficients and I don't know how to do it. I'm only a beginner with sas. From the results I see that x1, x2, x3 and…
Radojko
  • 61
  • 3
5
votes
2 answers

convert a SAS datetime in Pandas

I am using Pandas to read a Sas dataset using read_sas There is a datetime variable in the SAS dataset, which appears in Pandas as: 1.775376e+09 Once I convert it to str the date is: 1775376002.0 The corresponding date in SAS (not in my Pandas…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
5
votes
3 answers

Shortcut to comment selected code in SAS Guide

is there some shortcut to just comment the selected code in SAS Enterprise Guide? There is Ctrl + / to comment the selected line. But would be really useful to comment just a selected part of the code. Thanks.
Ana Ferreira
  • 79
  • 1
  • 9
5
votes
2 answers

.z syntax in SAS

I found this paper on SAS that includes (on the first page and some other parts) the following line of code: if trt1pn > .z then... I was wondering what the purpose of it can be. I had never seen the ".z" expression before. I though (and some…
datanalytics.com
  • 986
  • 7
  • 11
5
votes
3 answers

Why aren't SAS Macro Variables Local-Scope by Default?

I found this very helpful SO page while trying to resolve an issue related to macro variable scope. why doesn't %let create a local macro variable? So to summarize, writing %let x = [];or %do x = [] %to []; in a macro will: create a local-scope…
Max Power
  • 8,265
  • 13
  • 50
  • 91
5
votes
2 answers

Comparing strings with symbols from different alphabets

I want to compare two strings which contains symbols from different alphabets (e.g. Russian and English). I want that symbols which looks similarly is considered as equal to each other. E.g. in the word "Mom" letter "o" is from English alphabet…
PierreVanStulov
  • 425
  • 2
  • 11
5
votes
4 answers

Equivalent of Access Crosstab Query in SAS?

Here is my Input: ID Color 1 green 1 red 1 orange 1 green 1 red 2 red 2 red 2 blue 3 green 3 red Here is what I want in my output - a count of records by ID for each color: ID green red orange blue 1 2 2 1 …
oob
  • 1,948
  • 3
  • 26
  • 48
5
votes
1 answer

XML Syntax for SAS Stored Process

I am trying to complete the example on page 19 of the SAS BI Web Services Developers Guide. I have followed the instructions verbatim but am unable to get the stored process (automatically a web service) to return the correct result when I make a…
Ted Petrou
  • 59,042
  • 19
  • 131
  • 136
5
votes
1 answer

declare variabe in PROC SQL (SAS)

I am trying to use a variable on PROC SQL but i cannot find a proper way through the internet. I just want to apply the following code of T-SQL on PROC SQL: declare @example as int; set @example=2; select * from {table} where…
dimos
  • 147
  • 2
  • 9
5
votes
1 answer

Differences between SAS and SQL

Can anyone articulate what the key differences are between SAS and SQL? I haven't worked much with SAS but went on a weeks training course, and basically it seemed like the equivalent but more convoluted and was able to do graphs. Would appreciate…
hwilson1
  • 489
  • 1
  • 6
  • 17