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
100
votes
6 answers

Large, persistent DataFrame in pandas

I am exploring switching to python and pandas as a long-time SAS user. However, when running some tests today, I was surprised that python ran out of memory when trying to pandas.read_csv() a 128mb csv file. It had about 200,000 rows and 200…
Zelazny7
  • 39,946
  • 18
  • 70
  • 84
71
votes
10 answers

Nested ifelse statement

I'm still learning how to translate a SAS code into R and I get warnings. I need to understand where I'm making mistakes. What I want to do is create a variable which summarizes and differentiates 3 status of a population: mainland, overseas,…
balour
  • 741
  • 1
  • 6
  • 8
46
votes
2 answers

Experience with using h5py to do analytical work on big data in Python?

I do a lot of statistical work and use Python as my main language. Some of the data sets I work with though can take 20GB of memory, which makes operating on them using in-memory functions in numpy, scipy, and PyIMSL nearly impossible. The…
Josh Hemann
  • 940
  • 10
  • 12
26
votes
4 answers

Efficiently convert a SAS dataset into a CSV

Can anyone tell me what is the fastest way to programmatically convert a SAS dataset into a CSV file. I know I can use a data step and output to a file etc. But is that the only way? Thanks, Adnan.
Adnan
  • 2,949
  • 4
  • 29
  • 45
23
votes
5 answers

Is there a way to make SAS stop upon the first warning or error?

SAS likes to continue processing well after warnings and errors, so I often need to scroll back through pages in the log to find an issue. Is there a better way? I'd like it to stop as soon as the first error or warning appears so I can fix it and…
Two Bit Gangster
  • 973
  • 2
  • 9
  • 14
22
votes
1 answer

Do I need to call rollback if I never commit?

I am connecting to a SQL Server using no autocommit. If everything is successful, I call commit. Otherwise, I just exit. Do I need to explicitly call rollback, or will it be rolled back automatically when we close the connection without…
Derek
  • 3,087
  • 1
  • 21
  • 23
20
votes
7 answers

How to detect how many observations in a dataset (or if it is empty), in SAS?

I wonder if there is a way of detecting whether a data set is empty, i.e. it has no observations. Or in another saying, how to get the number of observations in a specific data set. So that I can write an If statement to set some conditions. Thanks.
mj023119
  • 675
  • 5
  • 12
  • 19
20
votes
3 answers

SAS function for using 'power' / exponential

I may be missing something obvious, but how do you calculate 'powers' in SAS? Eg X squared, or Y cubed? what I need is to have variable1 ^ variable2, but cannot find the syntax... (I am using SAS 9.1.3)
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
18
votes
2 answers

Limiting results in PROC SQL

I am trying to use PROC SQL to query a DB2 table with hundreds of millions of records. During the development stage, I want to run my query on an arbitrarily small subset of those records (say, 1000). I've tried using INOBS to limit the…
JDB
  • 25,172
  • 5
  • 72
  • 123
18
votes
1 answer

How can I find the first and last occurrences of an element in a data.frame?

I have searched exhaustively for a direct R translation for the FIRST. and LAST. pointers in SAS DATA steps but can't seem to find one. For those not familiar with SAS, FIRST. is a boolean that identifies the first appearance of a given element in…
asteri
  • 11,402
  • 13
  • 60
  • 84
17
votes
4 answers

What is the best non-SAS IDE for the SAS Language?

I am working on SAS code that will run under UNIX. Ideally the IDE will have: intelligent code formatting (autocomplete is not necessary). ability to transfer code to server via SFTP/SSH/SCP. Ability to execute code on the server via ssh and -e…
Jay Stevens
  • 5,863
  • 9
  • 44
  • 67
17
votes
3 answers

Opening SAS datasets for viewing from within a .sas program

Is there a way to open a SAS dataset for viewing (i.e., in the "ViewTable" window) from within a .sas file?
Lauren Samuels
  • 2,419
  • 3
  • 19
  • 20
17
votes
3 answers

Open SAS .egp file to view code without having SAS installed

Is there any solution to open SAS .egp file without having SAS installed on my pc? I need to open project.egp to check my old code but I don't have SAS anymore. Is there any other way to do that?
Residium
  • 281
  • 1
  • 4
  • 8
17
votes
5 answers

sas date - convert today() into yyyymmdd format

How do I convert a SAS date such as "30JUL2009"d into YYYYMMDD format (eg 20090730)? So for instance: data _null_; format test ?????; test=today(); put test=; run; Would give me "test=20090730" in the log...
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
16
votes
2 answers

meaning of group by 1,2,3,4

Someone can explain the code below to me? I am confused by Group by 1, 2, 3, 4, because there is no variable and value called 1, 2, 3, 4. proc sql; create table SampleData as select uniqID, Category, Grade, Value, count(uniqID) as CNT, avg(PRICE)…
user1481397
  • 393
  • 1
  • 9
  • 25
1
2 3
99 100