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

Parse all column names from table and put into macro variable (SAS 9.4)

Hi I have table which contains around 300 variable and I need to get all the column names (variables) into one macro variable (%let vars = [list of names of those 300 columns] ). Anybody knows how could I do that?
Alex T
  • 3,529
  • 12
  • 56
  • 105
2
votes
3 answers

Determining Server Context (Workspace Server vs Stored Process Server)

I'd like to conditionally execute code depending on whether I'm in a Workspace or Stored Process server context. I could do this by testing the existence of an automatic STP variable, eg _metaperson, but this wouldn't be very robust. Assuming I…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
2
votes
1 answer

SAS - how to 'sum up' based on consecutive occurrences

First time post so hopefully someone can kindly assist on this problem I'm facing within SAS EG (still learning SAS coding so please be kind!) If you see a snippet of the dataset below what I'm trying to do is tally up the scores (pts) by Ref based…
Rockshah
  • 77
  • 2
  • 11
2
votes
2 answers

adding space to character variables

when I run the following code, I see that the number in my character variable gets shifted as a value data test; input names$ score1 score2; cards; A1 80 95 A 2 80 95 ; run; proc print data=test; run; leading to a…
Nathgun
  • 115
  • 1
  • 1
  • 8
2
votes
5 answers

String cleanup and substring replacement

I have a table with 100k + rows. I'm trying to remove all instance of several sub-strings from one of the fields. The method I found so far basically calls tranwrd for every offending sub-string. There are three in the example below, but in the…
Ben
  • 485
  • 9
  • 19
2
votes
2 answers

Creating new variables using sas table according specific condition

I have a SAS table which has a numeric variable age. I need to construct new variables depending on the value of age. New variables should have this logic: if the 0<=age<=25 then age0=1 else age0=0 if the 26<=age<=40 then age25=1 else age25=0…
A2018
  • 77
  • 1
  • 1
  • 4
2
votes
1 answer

Error in loading package SASxport: object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing…
Qaswed
  • 3,649
  • 7
  • 27
  • 47
2
votes
1 answer

Missing values in a FREQ (SAS)

I'm going to ask this with an example... Suppose i have a data set where each observation represents a person. Two of the variables are AGE and HASADOG (and say this has values 1 for yes and 2 for no.) Is there a way to run a PROC FREQ (by…
Schwa
  • 129
  • 2
  • 9
2
votes
2 answers

CACHE access method

I'm debugging a Stored Process Web Application that writes a PDF to _webout. I'd like to avoid the following ERROR when running in a workspace session: ERROR: Function is only valid for filerefs using the CACHE access method. I've tried filename…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
2
votes
1 answer

By group controlling line colors/where clause

I want to plot Y by X plot where I group by year, but color code year based on different variable (dry). So each year shows as separate line but dry=1 years plot one color and dry=0 years plot different color. I actually figured one option (yeah!)…
2
votes
1 answer

SAS Merge two dataset with same variable name

I have the following program which merge two observations, but with same column name (variable), I want to know why in the merge result column A get dropped? data three; merge one(in=a) two; by ID; run;
xuanyue
  • 1,368
  • 1
  • 17
  • 36
2
votes
3 answers

Create 3d clustered bar chart 2 variables side by side using SAS 9.4

UPDATE: Here's a link to the complete dataset sas data I have a data set that consists of 11 provinces, semi annual time periods, a indicator, actual value and target value. I'm trying to create a 3d bar chart with axises province X time-period X…
DCR
  • 14,737
  • 12
  • 52
  • 115
2
votes
1 answer

SAS Provider for OLE DB (SAS.IOMProvider) doesn't work with ObjectPool

I'm using the SAS Integration Technologies COM components to connect to SAS Server from a C# .NET project. I want to submit statements to a SAS Workspace then load the output dataset from SAS using the OLE DB provider (SAS.IOMProvider). I am able to…
Will Rogers
  • 431
  • 1
  • 5
  • 14
2
votes
2 answers

how to multiply each row with each row of another matrix elementwise in sas?

I have a row matrix (vector) A and another square matrix B. How can I multiply each row of matrix B with the row matrix A in SAS using proc iml or otherwise? Let's say a = {1 2 3} b = {2 3 4 1 5 3 5 9 10} My output c would be: {2 6 12 1 10 9 5 18…
souravsarkar59
  • 127
  • 1
  • 1
  • 8
2
votes
2 answers

SAS: Specify newline character when input a text file

I'm quite new to SAS and have a very simple problem. I have a text file which is saved like this: 123,123,345,457,4.55~123,123,345,457,4.55~123,123,345,457,4.55 So all the data is written in a single line. The ~ character denotes the newline…
Constih
  • 145
  • 2
  • 8
1 2 3
99
100