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

In SAS use loop to rename indexed columns?

I have a dataset with variables as col1, col2, col3, ..., col15. I want to rename them to new1, new2, new3, ..., new 15. I can write 15 times the similar rename col1 = new1; in SAS but how can I achieve this using loop? Thanks.
Steve
  • 4,935
  • 11
  • 56
  • 83
5
votes
1 answer

Finding most similar phrases

I have two data sets. one is suppose the repair description Electric Component keyboard replacement The second data set is all the repair descriptions for all the customers who had previous repair phrase and later had some repair description.…
viji
  • 425
  • 2
  • 6
  • 16
5
votes
5 answers

Multiple WHERE IN that has to stay separated

I'm a SQL/SAS beginner. I wanna make an animals color report, which specifies quantity for each class black/brown, white/grey, gold/silver. I think it's not efficient to write the same code every time but i'm lost how to merge it into one: select…
Tom
  • 339
  • 2
  • 9
5
votes
2 answers

AIC calculation doesn't match in R and SAS for mixed model

I try to reproduce some SAS output using R. the method I want to reproduce is : Two way anaysis of variance with repeated measures on factor time using mixed models (covariance matrix = CS, Estimation method = REML) Everything looks fine exept…
Vincent Guyader
  • 2,927
  • 1
  • 26
  • 43
5
votes
1 answer

How to develop a third-party SAS PROC?

Is it possible, as a third party, to develop a SAS PROC? I'm thinking of something like a matlab toolbox or an R package. I've looked everywhere for info on how to do this, and the lack of discussion leads me to believe this is Not Done. Can…
5
votes
1 answer

How to read/write .xpt file with Python?

Am new to Python and looking for a solution to read/write xpt file(SAS data set) using Python. I got to know its possible using Python from this link. But then the code is not working as expected. Anything missing in this code, whether to include…
V-T
  • 756
  • 2
  • 9
  • 22
5
votes
1 answer

PROC DS2 performance issues

I was trying to use proc ds2 to try and get some performance increases over the normal data step by using the multithreaded capability. fred.testdata is a SPDE dataset containing 5 million observations. My code is below: proc ds2; thread…
reecec
  • 73
  • 5
5
votes
3 answers

SAS - Break out of macro %DO loop

I know there exists the LEAVE statement for data step DO loops to terminate the current loop. I cannot find, however, documentation for a corresponding macro command. I've tried %LEAVE but that appears not to be defined. Does SAS not have a…
Lorem Ipsum
  • 4,020
  • 4
  • 41
  • 67
5
votes
1 answer

SAS libname JSON engine -- Twitter API

I'd like to use the SAS libname JSON engine instead of PROC GROOVY to import the JSON file I get from the Twitter API. I am running SAS 9.4M4 on OpenSuse LEAP 42.3. I followed Falko Schulz's description in how to access the Twitter API and everthing…
Johannes Bleher
  • 321
  • 3
  • 15
5
votes
1 answer

Read a sample from sas7bdat file in R

I have a sas7bdat file of size around 80 GB. Since my pc has a memory of 4 GB the only way I can see is reading some of its rows. I tried using the sas7bdat package in R which gives the error "big endian files are not supported" The read_sas()…
5
votes
1 answer

polynomial terms in proc logistic and other regressions

I'd like to do the following regression proc logistic data=abc model y = x x*x x*x*x ....; run; Is there a shorthand to generate these polynomial terms? Thanks.
djacky
  • 51
  • 1
5
votes
2 answers

Which statistics is calculated faster in SAS, proc summary?

I need a theoretical answer. Imagine that you have a table with 1.5 billion rows (the table is created as column-based with DB2-Blu). You are using SAS and you will do some statistics by using Proc Summary like min/max/mean values, standard…
user3714330
  • 679
  • 12
  • 32
5
votes
2 answers

UNIX Importing LARGE csv into SQLite

I have a 5gig csv file (also as a sas datafile, if it would be easier) which I need to put into a sql database so I can work with it in R. The variables names are all contained in the first observation line and are double quoted. There are 1000+…
MaDMaD Mad
  • 193
  • 1
  • 7
5
votes
2 answers

Is there a retain function in python? I want to transfer SAS code to python

I want to transfer SAS code to python, and cannot find a retain function in python. The data is like : type_id amount 1 100 1 200 1 400 2 0 1 200 1 300 2 0 1 …
juanbin
  • 83
  • 1
  • 9
5
votes
3 answers

Macro variables issue when using call execute

I have 2 macros below that I am trying to execute 1 after another like a loop using a metadata table and the call execute command in a data step. macro %TWO requires the global variable &names_agg. that is supposed to be created in macro %ONE.…
MarkG
  • 83
  • 1
  • 5