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

How to get Number of days between two dates in SAS

I have a table named case_DataTable_d in which column name value_dt have different date values. I want get number of day difference between that date and date of today. This is my code proc sql noprint; create table daystoOverdue_list as select…
Azeem112
  • 337
  • 1
  • 8
  • 23
2
votes
2 answers

How to add a custom fitted line to SAS SGplot Scatter

I have a simple SAS data set I am plotting as a scatter plot, my two questions are: I am trying to adjust the y-axis without excluding the (0.02,51) data point but I need the y-axis to only show 60 to 160 by 20. When I define this it excludes that…
Bfran
  • 21
  • 2
2
votes
1 answer

SAS search multiple values in a string

I have two SAS datasets with (assume for simplicity) one char variable in each. The first dataset has a variable with company description (sometimes including city, sometimes not; a messy field) and a second dataset has a variable, where all cities…
VR6
  • 63
  • 4
2
votes
1 answer

Simply adding two macro variables in SAS

I'm currently trying to simply add two macros being created. But I'm struggling quite badly with this. It seemed very straight forward at the beginning but.. So here is what I'm trying to do.. %let A = 5; %let B = 10; %let AB = &A + &B; %put…
Brian
  • 161
  • 11
2
votes
1 answer

How to remove a first row or first group of rows in a specific time interval using SAS?

I'm working with SAS and I have a data frame like this: table1 +------+------------+-----------+ | name | date | time | +------+------------+-----------+ | A | 7-May-08 | 09:01:41 | | A | 7-May-08 | 09:01:41 | | A | …
Amin Karimi
  • 407
  • 2
  • 16
2
votes
1 answer

Create Row Number Column by Two Columns SAS

I want to add a row number column to a SAS data set based on the values of two columns. Type_1 and Type_2 columns are what I have and the Row Number is what I need. Type_1 Type_2 Row Number A 1 1 A 1 2 A 2 1 A …
Jarom
  • 1,067
  • 1
  • 14
  • 36
2
votes
3 answers

How to remove a row and the next row (rows) if it is in another table using SAS?

I'm working with SAS and I have a data frame like this: Table1: +------+------------+-----------+--------+ | name | date | time | price | +------+------------+-----------+--------+ | A | 7-May-08 | 11:12:41 | 1 | | A | …
ary
  • 151
  • 1
  • 2
  • 14
2
votes
2 answers

Can I not use a function in an insert statement?

It seems as though I cannot use a SAS function in an insert statement: proc sql; create table tq84_tab (col char(100)); insert into tq84_tab values (repeat('foo ', 10)); quit; When I run the code, I am getting: insert into tq84_tab…
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
2
votes
2 answers

FCMP with VARARGS not working as expected?

While researching FCMP to help answer another question on here, I was left a bit perplexed by how proc fcmp works when using the VARARGS option in order to be able to call that function with a variable number of arguments. The sas support page for…
user2877959
  • 1,792
  • 1
  • 9
  • 14
2
votes
3 answers

Finding out the size of a Netezza table using UNIX SAS

What syntax / tables can be used to determine the size (Gbs) of a Netezza table? I am accessing via UNIX SAS (either ODBC or libname engine). I assume there is a view which will give this info?
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
2
votes
1 answer

Proc FCMP - default parameter values

Is it possible to specify a default value for proc fcmp function parameters? Something like this: proc fcmp outlib=work.funcs.funcs; function my_func(param1, param2='default_value_here' $); * DO STUFF; endsub; run; From the documentation…
Robert Penridge
  • 8,424
  • 2
  • 34
  • 55
2
votes
1 answer

Different Result from SAS Proc univariate and R quantile function

I used function quantile in R to do the calculation of 90th, 75th, 50th, 25th percentile, but then my colleague used SAS proc univariate to do the same calculation, we got quite different results (for example, 90th percentile from R is 47.36, but…
Kelly Lu
  • 21
  • 3
2
votes
1 answer

What does testing if a variable is not equal to nothing do?

I came across SAS code recently that looks something like this: %if var_name ~= %then %do; flag = 1; %end; I understand that ~= means "not equal", but there appears to be nothing here for the variable to be compared to. Can someone shed any…
Kenneth
  • 23
  • 2
2
votes
1 answer

SAS protect Excel worksheet with DDE

I want to manipulate an existing Excel sheet with DDE using SAS: I have the following code (be careful! I use z for r(ows) and s for c(columns) because of German language settings in Excel): option noxwait noxsync; x call "C:\Program Files…
zuluk
  • 1,557
  • 8
  • 29
  • 49
2
votes
3 answers

Converting autocall libraries to stored compiled macros

We have hundreds of macros across several autocall libraries that I'd like to compile using the MSTORE facility. The problem is that some of those libraries are used on other sites - and we don't want to add /STORE to every definition, as then it is…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
1 2 3
99
100