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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
30 views

Full Outer Join gives results similar to Inner Join [closed]

Data source is DB2 and I am using SAS. I can use SAS or Proc SQL for this. I have a table_A with such data. I have another table_B with such data I want the following output I have tried the ...
Rogue258's user avatar
  • 111
0 votes
1 answer
24 views

How to create an if then statement to drop dates for the same observation

I have an example subset of 1 patient that where I created 2 separate dates. That is "Date" and "Pending_Date". I also created a variable where each row is either Pending='YES' or ...
ElHombre's user avatar
0 votes
2 answers
39 views

how to create standard text file format for National death index in sas or R

I want to create a standard text file format with 100 positions per patient as in the attached screenshot ( ignoring the first 2 rows) to get the death date as requested by the National Death Index. ...
Mohamed Rahouma's user avatar
0 votes
0 answers
24 views

This SAS code performs 10C9 for both means and CVs for width and length variables, is there a way to do 10C8, down to 10C1 in the same SAS code?

This SAS code performs 10 Combination 9 for both means and CVs for width and length variables, is there a way to do 10 Combination 8, down to 10C1 in the same SAS code? data yourdata; ...
Emmanuel Alagbe's user avatar
0 votes
0 answers
22 views

MonYear looping with variables to accumulate totals for 2 variables

I have currently managed to obtain from startdate and enddate a loop to include all variables by formatting the date and running the following; First step data loandata2; set loandata1; date = ...
John Seb's user avatar
0 votes
1 answer
27 views

Datastep2: converting string to timestamp

I'm struggling with converting a string to a timestamp. This is quite easy in normal Datastep, but not for me in DS2. How would I have to modify the DS2 code so that I get the same result as in the ...
NaHolla's user avatar
  • 85
1 vote
1 answer
27 views

How to remove a set of words from a character variable?

I want to compare two columns that have people names. I realized that many names differ mainly because they have words like "DA", "DO", "DE" "DAS" "DOS&...
LuizZ's user avatar
  • 957
-1 votes
2 answers
38 views

How do I loop through 1000 records at a time using a SQL Pass-thru Query to Oracle in SAS [closed]

AS there is the 1000 record limitations reading in data in Oracle, how would I read in 1000 rows at a time from a SAS dataset so that I can create a macro variable list to pass to the SAS SQL Pass-...
A. MATULA's user avatar
0 votes
2 answers
61 views

year-data missing for the date range in two columns in SAS with id

I have data in the following format Startdate perm_id amount enddate 01JUL2004 4294970232. 787560 01JUL2009 10AUG2005 4294970232 797880 01JUL2009 31JAN2007 ...
John Seb's user avatar
0 votes
2 answers
31 views

how to take a random number generated in sas and use that to populate a whole column in another dataset?

I know how to generate a random date in sas but then I want to take that date and use it to populate a column in another dataset? So for example I have a dataset with columns a,b,c called pop, and I ...
computerprogram's user avatar
2 votes
1 answer
32 views

Joining Function outputs with existing columns as new variable

I'm looking to do a conversion from datetime/pandas date's storage system to the one SAS uses for the purpose of joining with a variable. Basically would like to go from this: ID date 101 20-01-01 ...
TDeramus's user avatar
  • 101
-2 votes
0 answers
27 views

I tried to remove duplicates but there are blanks in one field, how to remove duplicates/blanks for a certain criteria using proc sql

I have a query that all duplicates are removed but there are a few still there because one column has a blank and the other has a value resulting in a duplicate. How would you go about removing the ...
gavincann9's user avatar
1 vote
2 answers
34 views

PROC SQL subquerying

I have this table: library table attribute_exclusion lib_A Table A ('column_A','column_H') lib_A Table B ('column_C','column_X') And I want to get all columns from SASHELP.VCOLUMN in my HAVE table ...
JPOLIVA's user avatar
  • 63
-1 votes
0 answers
13 views

running a long pyspark script in databricks [closed]

I'm trying to run a long PySpark script in databricks, about 3000 lines. But I keep getting OOM errors because the resulting spark DAG is extremely complicated. Any idea how to optimize this? this a ...
Abhishek Mangla's user avatar
0 votes
1 answer
29 views

Cumulative loan data with dates for a given firm in SAS

I'm working with a dataset dealscan and attempting to combine the tranche_amount for a given firm, subject to active date and maturity date, so I have a sum of total over a given period. I have used ...
John Seb's user avatar
0 votes
1 answer
15 views

How to extract entire row of max and min using proc function in SAS?

I have to identify which sneaker (variable 1) is matched (same row) with the highest and lowest sales (variable 2) by using a SAS procedure function. Current code: PROC MEANS DATA = M4.sneaker min max;...
Robyn O'Halloran's user avatar
0 votes
1 answer
21 views

Is there a way to do an average over a whole SAS table with SAS?

Say if I had a table column1 column2 column3 1 2 3 5 7 9 1 2 3 And I wanted to find the average so I wanted to sum everything up in the whole table and divide it by the number of data points, so ...
computerprogram's user avatar
0 votes
1 answer
11 views

Convert from char to Num a list of variables

I use the following code to add empty columns to my data set. How can I specify that they must be numeric instead of character? Thank you in advance data mydb; set all; ...
NewUsr_stat's user avatar
  • 2,353
0 votes
2 answers
22 views

SAS Community: How do I remove duplicates of one variable but only if it meets the condition of another variable?

I have a large dataset in SAS with two main variables that are relevant for this quesiton: 1. ID: every row has its own unique ID, however some rows are repeated therefore many IDs are repeated as ...
randsakka's user avatar
-4 votes
1 answer
21 views

write the code to read every fifth observation from the sashelp.class [closed]

We have the following data, we have to write code that reads every fifth observation from the data 1 Alfred M 14 69 112.5 2 Alice F 13 56.5 84 3 Barbara F 13 65.3 98 4 ...
Dheeraj   singh 's user avatar
0 votes
2 answers
17 views

How to convert SAS date from 01/01/00 to 01-01-00?

I am trying to change a formatted date from 01Jan2000 to 01-01-00? I currently have been able to format it to 01/01/00 but cannot figure out how to change the / to -? Code: data stocks; set sashelp....
Robyn O'Halloran's user avatar
0 votes
1 answer
29 views

Encoding SAS data in ANSI format in Python

I'm trying to import a 4 gb SAS data into python. Inside there are firms' information including names and other codes. However there seems to be some error with encoding. I try to use the read_sas in ...
Chengmou Lei's user avatar
0 votes
1 answer
39 views

make separat dataframes of list.files - R

Hi I have a list of SAS files; filelist <- list.files('SASfilenames', full.names = TRUE) Filelist contains 15 filepaths to 15 SAS files, and I want to make these as 15 separat dataframes. How can ...
Hellihansen's user avatar
0 votes
2 answers
14 views

SAS INFILE time informat for just mm:ss?

I'm importing a .txt file into SAS and I need to convert a time column in mm:ss format into a numeric variable in the informat part (eg: 1:06 would become 66 seconds). I've tried using time, time4, ...
go4ino's user avatar
  • 5
0 votes
0 answers
17 views

Trying to import a STC file into SAS

I am a student new to sas working on a desktop provided by my University. I am trying to import a STC file into SAS 9.4, but am having trouble. I have tried simply right-clicking on the file, and then ...
Jamshed Mistry's user avatar
0 votes
1 answer
23 views

SAS Syntax error in macro and setting up local variables

I'm very new to SAS. I've imported data from two excel spreadsheets. From the first, I calculated new variables names Sorptivity and Kfs. This step works fine. I then merged the newly created ...
Segeana's user avatar
  • 13
0 votes
2 answers
18 views

Counting variables that are missing by group in SAS

I am not sure how to do what I want. Basically I have a group variable of organizations I am interested in, I would like to look across the data set see how many variables are empty for each ...
AJYAss's user avatar
  • 1
-4 votes
1 answer
14 views

How to convert 03AUG2023:00:00:00.000000 time to this sas format 2006553600

Ineed to convert below date into sas date 03AUG2023:00:00:00.000000 time to this sas format 2006553600
Arun P.A's user avatar
0 votes
2 answers
20 views

Conditionally Assign a Libname in SAS

I want to conditionally assign a libname in sas based on a already set macro variable, for one option of this if statement I also want to include a datastep. This is what I'm currently trying: %if &...
MLPNPC's user avatar
  • 486
0 votes
2 answers
25 views

Conditionally set a %let statement SAS

I was hoping someone could help with %if %then statements in SAS. I want to conditionally set a macro variable so I was trying to do it this way: %if &stress_test. = "Y" %then %let ...
MLPNPC's user avatar
  • 486
0 votes
1 answer
54 views

Merge/Group data in SAS

I have the following dataset Id com typ cust bu tar item item_sufx part line dtn_cd geo_con sign 10 ARF 3 2585 12 100 4587 800 1 1 1 ZL-UK-23 + 10 ARF 3 2585 12 100 4587 800 1 2 1 ZL-US-22 - 10 ...
Rogue258's user avatar
  • 111
0 votes
1 answer
36 views

Gradient decent

I am trying to perform gradient decent in data set with binary target variable flag_bad and iam facing many problems with %do statement and updating the parameters value %let learning_rate=.01; %let ...
mohamed magdy's user avatar
0 votes
0 answers
12 views

What is Shortcut Key for Import Data in SASEG

i just want to know what is the shortcut keys for Import Data Window of SAS EG (Sas Enterprise Guide) (Windows) I know its a basic question, but i really try to find the shortcut key on the internet ...
Vasant Raval's user avatar
0 votes
0 answers
10 views

SAS EG running wrong file

I've been having a weird problem. Every so often, I'll run a program in SAS EG that's part of a project, and SAS EG will, for reasons unclear to me, run a different file in that project, instead of ...
N0DuckingWay's user avatar
1 vote
1 answer
28 views

How to calculate minimum , maximum, total and averge age from sashelp.class;

Here I have sashelp.class. In this we have 19 rows and 5 columns. I want to calculate the minimum, maximum, total and average age from the sashelp.class by using only data step. Total rows: 19 - ...
Dheeraj   singh 's user avatar
0 votes
0 answers
15 views

How to implement the missing at random (MAR) assumption in mixed model using SAS proc mixed?

Here is example data for repeated measure clinical trail study wehre ResVal is the response variable and there are two treatment arm. Data are collected in five timepoints. ` data draft; input subID ...
Uddin's user avatar
  • 754
0 votes
1 answer
30 views

SAS Create Macro variables using a macro

I have the following dataset: A1 A2 A3 B 1 0.89606 B 2 0.10058 B 3 0.00336 C 1 0.88083 C 2 0.07205 C 3 0.04712 L 1 0.93198 L 2 0.06802 L 3 0.0000 R 1 0.8096 R ...
MLPNPC's user avatar
  • 486
0 votes
0 answers
19 views

Transferring data from one ESP Project to another in SAS Viya 4.0. Azure Kubernetes

I am working on a project where I want to have two ESP Projects in SAS Viya 4.0 communicate with eachother. The plan is to have one ESP project running with a source window set up as a kafka consumer ...
olejonas's user avatar
0 votes
3 answers
33 views

Why is it looking for formats ... and where are they? (SAS)

I'm trying to run a macro (mcartest). Here is the beginning of the code (full code is here, although I modified it to allow entering options in the macro call): macro mcartest (data=,items=); /* ...
Steve Scher's user avatar
0 votes
2 answers
27 views

SAS count observations based on condition

I have two columns: member ID and member score. What I need to do is count the number of members if their score is greater than a specific value. I was thinking some sort of do over loop... For ...
Betsy_Ann's user avatar
0 votes
0 answers
21 views

Combining two fips variables to create one fips code variable

I have one large SAS dataset and I am currently trying to create one FIPS code variable and at the moment I only have fipsStateCode and fipscountycode. Could someone please give me some guidance on ...
Adrianna 's user avatar
0 votes
1 answer
34 views

SAS and Visual Studio Code Snippets [duplicate]

I'm working with SAS Enterprise Guide for the first time, and it's in a highly secure remote environment. So far, I find that auto-complete when writing code is virtually nonexistent, even though I've ...
Tom's user avatar
  • 86
0 votes
2 answers
44 views

Editing SAS variables with a 2-part hierarchical suffix based on year and month

I am trying to edit variables in a sas dataset. The dataset has multiple types of variables which repeat for quite a few years, each month. The variables are character variables and have names like '...
user3758250's user avatar
1 vote
1 answer
31 views

SAS proc freq or proc sql to obtain frequency of a subset of data and whole data

I am trying to obtain frequency based on two different datasets (with their subsets). Consider the following example DATA Group1; INPUT Subject_ID education; DATALINES; 1 LowerPrimary 2 Secondary 3 ...
John Majimboni's user avatar
0 votes
2 answers
47 views

SAS get the 1st format DATE and NUM attribute from dictionary table

Good day all, I need to get the name of the 1st column formatted with DATE and NUM of a list of tables. I tried something like this in my slq proc and got results, but not the ones i liked. I think ...
JPOLIVA's user avatar
  • 63
0 votes
2 answers
22 views

How to calculate duration based on ID groups between two specific periods that may have missing dates?

Let's say I have this example data set data df; infile datalines delimiter=','; attrib id length = $8 cycle length = $8 date length = 8 format = mmddyy10. informat = mmddyy10. ; input ID ...
Anas116's user avatar
  • 793
0 votes
0 answers
11 views

proc template to fix attribute class header in proc report sas

i am trying to put in proc template the style of proc report PROC TEMPLATE; DEFINE STYLE Styles.mine; PARENT=styles.htmlblue; CLASS systitleandfootercontainer / htmlstyle="border:...
d r's user avatar
  • 1
0 votes
1 answer
16 views

Extract only file_path from SAS variable

I'm looking to extract just the directory path from a File_Path variable, excluding the file name in SAS. Can someone assist with this /start_file_pth/data/sg/prod5/file_path/dataset1.sas7bdat.gz /...
vmaha13's user avatar
  • 21
0 votes
2 answers
24 views

Potential deadlock using Proc SQL Update in SAS

I am trying to update a variable 'clnwash' in a dataset based on multiple conditions in a different dataset using prog sql update. I'm new to SAS and I'm having a hard time getting the following code ...
Dominique Medaglio's user avatar
0 votes
1 answer
15 views

How to make a dataframe based on the condition of one of many answers for the same ID?

Let's say I have this dataset I created data df; input ID status$; datalines; 1 YES 1 YES 1 YES 2 NO 2 YES 2 YES 2 YES 2 YES 3 NO 3 NO 3 NO ; run; What I wish is the output as follows with the ...
Anas116's user avatar
  • 793

1
2 3 4 5
314