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

Insert variables into SAS using JAVA (IOM Bridge). Should i use CORBA stubs and JDBC or is there any other alternative?

This is part of my code snippet WorkspaceConnector connector = null; WorkspaceFactory workspaceFactory = null; String variableListString = null; Properties sasServerProperties = new Properties(); sasServerProperties.put("host",…
Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75
7
votes
3 answers

Running SAS Stored Process in Excel fails after two runs

I hope this is an appropriate place to ask this question. I have recently built a data analysis tool in Excel that works by submitting inputs to a SAS Stored Process (as an 'input stream'), running the processes and displaying the results in…
7
votes
5 answers

read.sas7bdat unable to read compressed file

I am trying to read a .sas7bdat file in R. When I use the command library(sas7bdat) read.sas7bdat("filename") I get the following error: Error in read.sas7bdat("county2.sas7bdat") : file contains compressed data I do not have experience with SAS,…
user3641630
  • 311
  • 1
  • 3
  • 11
7
votes
2 answers

IF-THEN vs IF in SAS

What is the difference between IF and IF-THEN For example the following statement if type='H' then output; vs if type='H'; output;
Elvis
  • 255
  • 3
  • 11
7
votes
3 answers

How can I create an ODBC connection to SAS?

I'm writing a program that needs to access SAS data. I've downloaded the ODBC drivers for SAS and installed them, but I need to be able to create ODBC connections on the fly, programmatically. The following code (in Python) seems like it should…
Chris B.
  • 85,731
  • 25
  • 98
  • 139
7
votes
2 answers

Reading a period as character value in SAS

I am reading a period '.' as a character variable's value but it is reading it as a blank value. data output1; input @1 a $1. @2 b $1. @3 c $1.; datalines; !.. 1.3 ; run; Output Required ------ -------- A B C A B C ! …
athresh
  • 553
  • 6
  • 11
  • 24
7
votes
3 answers

SAS: How to output only the part of PROC CONTENTS that displays the variables in the data set?

I'm in a beginner SAS class and we are required to display only the section of the PROC CONTENTS output that shows the variables in the dataset. For example, when you do proc contents data=whas.heart3; run; The output is 3 tables. The 3rd table is…
jstewartmitchel
  • 171
  • 3
  • 3
  • 11
7
votes
1 answer

Exchange Server and SAS 9.1.3/9.2

has anyone successfully interacted with a microsoft exchange server in SAS 9.1.3 or 9.2? i know it can be done with SAS Ent. Guide 4.x, but i'm not interested in that route if regular SAS can do it.
rkoopmann
  • 1,136
  • 7
  • 10
7
votes
2 answers

Replace missing values in SAS

How do you replace all missing values with zeroes in SAS? I have a text file that I dump into SAS to process some geo data, but whenever it has a missing value it breaks the operations. Is there a way to change this without specifying each field? I…
user2444108
7
votes
1 answer

Hotkey to run program in SAS?

I know in R I can use control+r to run my program code. I am wondering if there is an equivalent hotkey in SAS? If not, is there a way to 'program' one into SAS?
user27008
  • 600
  • 3
  • 15
  • 24
7
votes
5 answers

SAS - How to get last 'n' observations from a dataset?

How can you create a SAS data set from another dataset using only the last n observations from original dataset. This is easy when you know the value of n. If I don't know 'n' how can this be done?
Riyaz Iqbal
  • 71
  • 1
  • 1
  • 3
7
votes
7 answers

How to convert String to Date value in SAS?

I want to convert a String to Date in SAS, I tried: data _null_; monyy = '05May2013'; date = input(substr(strip(monyy),1,9),yymmdd.);; put date=date9.; run; But it did not work. Can this be done?
SAS_learner
  • 521
  • 1
  • 13
  • 30
7
votes
2 answers

"For in" loop equivalent in SAS 9.3

I'm searching for a while an equivalent of the for in loop (like in Python or in R) in SAS 9.3 macro language. The DO loop seem's to be the solution but did't work exactly as I want. I founded a way to do it in a data step with a DO loop but it…
jomuller
  • 1,032
  • 2
  • 10
  • 19
7
votes
1 answer

Substitute text in a macro variable in SAS

I want to change any instances of a period in a macro variable to underscore. What am I doing wrong? %let pow=0.1; %let x = %sysfunc(tranwrd(&pow,".","_")); %put x=&x; Output: x=0.1
itzy
  • 11,275
  • 15
  • 63
  • 96
7
votes
8 answers

Using SAS Macro to pipe a list of filenames from a Windows directory

I am trying to amend the macro below to accept a macro parameter as the 'location' argument for a dir command. However I cannot get it to resolve correctly due to the nested quotes issue. Using %str(%') does not work, neither do quoting functions…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124