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

SAS Syntax Highlighting in Sublime

I would like to be able to use Sublime 3 as my SAS text editor but cannot seem to configure Sublime to do so. I've visited http://implementing-vdw.blogspot.com/2012/10/new-sublime-text-package-available-for.html and haven't been able to actually get…
Lyle
  • 219
  • 1
  • 4
  • 12
8
votes
2 answers

infile .csv file in sas with header

I have a csv file which named dataset1.csv and it contains header with 3 variables att1 (character), att2 and att3 (numeric data). I tried following code filename test 'C:\Users\1502911\Desktop\Practice\SAS\Dataset'; data dataset1; infile…
useR
  • 3,062
  • 10
  • 51
  • 66
8
votes
3 answers

Would overwriting the existing SAS dataset take more time?

I got a short question - If we are creating a SAS dataset say - Sample.sas7bdat which already exists, will the code take more time to execute (because here the code has to overwrite the existing dataset) than the case when this dataset was not…
in_user
  • 1,948
  • 1
  • 15
  • 22
8
votes
1 answer

Sorting an almost sorted dataset in SAS

I have a large dataset in SAS which I know is almost sorted; I know the first and second levels are sorted, but the third level is not. Furthermore, the first and second levels contain a large number of distinct values and so it is even less…
Nick
  • 645
  • 7
  • 22
8
votes
4 answers

SAS: rearrange field order in data step

In SAS 9, how can I in a simple data step, rearrange the order the field. Data set2; /*Something probably goes here*/ set set1; run; So if set1 has the following fields: Name Title Salary A Chief 40000 B Chief 45000 Then I…
Dan
  • 9,935
  • 15
  • 56
  • 66
8
votes
4 answers

SAS proc export to CSV: how to add double quotes

New to this, so apologies. I have a file in SAS that I need to export as a CSV and I need to add double quotes to all fields. How can I accomplish this? Thanks in advance.
Scott Grayson
  • 81
  • 1
  • 1
  • 2
8
votes
3 answers

SAS code stops running after submit, nothing in log either

I am writing a SAS program which also uses some macros. However, SAS suddenly stopped running the codes that I submitted. If I select and submit a part of the code, I can see it copied in the log but that's it. No note, error or warning. Neither is…
user3714321
  • 91
  • 1
  • 2
8
votes
2 answers

Does SAS have an inline if function or ternary operator?

I'm trying to concatenate a long string in SAS and it would be helpful to have an inline if function or ternary operator so that I can nest IF statements in the concatenation. I can't find mention of this in the docs. In a DATA step, I'd like to do…
Clay
  • 2,949
  • 3
  • 38
  • 54
8
votes
1 answer

Sample size and power calculation in r as viable alternative to proc power in SAS?

So I am trying to see how close the sample size calculations (for two sample independent proportions with unequal samples sizes) are between proc power in SAS and some sample size functions in r. I am using the data found here at a UCLA website.…
user27008
  • 600
  • 3
  • 15
  • 24
8
votes
1 answer

Plotting a shape file with ggplot2 error

Over the last few days I pretty much dove head first into using R for mapping. I have used R extensively for modelling etc. but not this kind of work before. I have some questions and issues regarding shapefiles, how they're read and so on. I have…
dom_oh
  • 867
  • 2
  • 11
  • 21
8
votes
2 answers

communicating with SAS datasets from R

I have a bunch of datasets that are in SAS format. I would like to avoid using SAS since I think R provides more than enough functionality for me. Therefore, is there a package that would allow me to interact with the SAS datasets from R? I have…
Alex
  • 19,533
  • 37
  • 126
  • 195
7
votes
4 answers

lag function doesn't work in SAS

Here is the part of my program.(oldindex and oldreadmit is in retain commend) The problem is it works for oldindex=1 then readmit=1 but doesn't work lag(oldreadmit)=1 then readmit=1. Could you tell what's the problem? Thanks in advance! else if 0<…
user1238178
  • 135
  • 3
  • 10
7
votes
3 answers

Observation number by group

In R I have a data frame with observations described by several values one of which is a factor. I have sorted the dataset by this factor and would like to add a column in which I would get a number of observation on each level of the factor…
twowo
  • 621
  • 1
  • 8
  • 15
7
votes
3 answers

Error handling on sockets in SAS under OpenVMS

I'm using SAS 9.2 on OpenVMS to connect to an external data source over a socket specifed with a filename statement: filename extsrc SOCKET "extserver:port" recfm=v; data foo; infile extsrc; input; .... some statements to read stuff ...; run; This…
jilles de wit
  • 7,060
  • 3
  • 26
  • 50
7
votes
1 answer

converting format (from date to numeric) using SAS

I am working with a dataset in SAS, containing many variables. One of these variables is a DATE variable and it has a date/time format. It looks like this: 12FEB97:00:00:00 27MAR97:00:00:00 14APR97:00:00:00 Now the thing is that I would like…
Laszlo
  • 251
  • 1
  • 4
  • 13