Questions tagged [datastep]

SAS datastep programming is the basic method of manipulating data in SAS, a 4G Statistical programming language.

This tag is intended for questions involving SAS datastep programming. It might be more appropriately answered by a SAS programmer, rather than a SAS user primarily focused on the statistical side.

SAS datastep programming involves anything between the 'data' statement and a step boundary (most commonly, 'run;', or another 'data' or 'proc' statement). It is used in SAS to input data from text files / database tables or other SAS programs, to manipulate data, and to output data to text files / database tables.

245 questions
0
votes
1 answer

Transform Ordered Values to Paired

I'm looking to transform a set of ordered values into a new dataset containing all ordered combinations. For example, if I have a dataset that looks like this: Code Rank Value Pctile 1250 1 25 0 1250 2 32 …
Ian
  • 35
  • 1
  • 4
0
votes
1 answer

SAS check field by field

I try build little check process. One proc sql generated one row table (and 13 fields) and next step I need check that chosen field in the table has value <> 0. Below my current (not completed) code with example table "have": data Have; input…
DarkousPl
  • 85
  • 1
  • 10
0
votes
0 answers

GROUPING BY DATETIME IN SAS DATA STEP

My data is in below form account_no transaction_start_dt_tm RECTYPE 34842765 23APR2017:14:34:00.000000 ICU 34842765 25APR2017:17:26:00.000000 ICU 34842765 28APR2017:14:18:00.000000 LLOC I…
A. MATULA
  • 31
  • 1
  • 7
0
votes
2 answers

sas reading files with space as delimiter

I have a datafile which uses blank space as delimiter. I want to write a data step to read this file into sas. The fields are not separated by a single blanks in most of the cases the fields are separated by more than 10 blanks spaces.I have checked…
megjosh
  • 101
  • 1
  • 9
0
votes
2 answers

SAS retain value and assign to new variable

I have the following data EMPID XVAR SRC ABC PER1 1 ABC 2 XYZ PER1 1 XYZ 2 LMN PER1 1 LMN 2 LMN PER2 1 LMN 2 LMN 2 LMN PER3 …
babsdoc
  • 693
  • 2
  • 11
  • 24
0
votes
2 answers

How do I subset data with arrays in DATA STEP (SAS)?

DATA output; SET arbitrary_table; ARRAY arrayname $ arrayname_1 - arrayname_10; DO i = 1 TO 10; IF arrayname(i) = "x"; END; RUN; The above code won't work. I'm trying to only show observations where one of the arrayname…
0
votes
2 answers

How to select rows from a dataset with specific criteria applied to each subset in SAS Enterprise Guide

I have the following table: COMPANY_NAME | GROUP | COUNTRY | STATUS COM1 | 1 | DE | DELETED COM2 | 1 | DE | REMAINING COM3 | 1 | UK | DELETED COM4 | 2 | ES | DELETED COM5…
sonarclick
  • 73
  • 8
0
votes
1 answer

data driven put with different formats challenge

I wanted to come here with this challenge I'm facing in these days. Basically for each record, a different format should be used in a put statement, and it is defined in the data in theirselves. The challenge is not to split the datasteps and…
stat
  • 699
  • 3
  • 10
0
votes
1 answer

how to set multiple data sets in the work folder using a Do loop?

I have 100 individual data sets of demographic information with distinct district names created in my work folder in the following format"; data exampleofdistrict; input districtname$ ASIAN BLACK COLORED WHITE; cards; Aberdeen 0.13 69.14 …
Nathan123
  • 763
  • 5
  • 18
0
votes
1 answer

SAS Reverse Column Order

Issue: I'm looking to reverse the order of all columns in a sas dataset. Should I achieve this by first transposing and then using a loop to reverse the order of the columns? This is my logic... Step One: data pre_transpose; set…
datanalyst
  • 351
  • 1
  • 3
  • 15
0
votes
3 answers

SAS data step view and data wrap in a macro for loop

For a university research project I am retrieving data from WRDS via SAS and am relatively new to SAS. I am trying to retrieve data in a specific interval provided by WRDS which actually works very for me; the structure is as follows [1]Define some…
eternity1
  • 651
  • 2
  • 15
  • 31
0
votes
1 answer

SAS data step error "too long for buffer"

I am just trying to load a SAS file someone else sent. I can open the dataset by just clicking on it and I can run proc contents. However, when I tried to copy the data to the work library, or run some summary statistics, this error message…
whyq
  • 11
  • 1
  • 5
0
votes
2 answers

Rolling sum for last 3 hour records of just one column in SAS

Everyone, What I need is to calculate for every record (every row) for the last 3 hour sum of usage (Usage is one of the columns in dataset) grouped by User and ID_option. Every line(row) represent one record (one hour have about million records).…
jovicbg
  • 1,523
  • 8
  • 34
  • 74
0
votes
1 answer

Is there a way to force cleansing the raw data before importing it via a data step, in SAS?

SAS EG I have a Tab delimited text file that has to be imported every month. So I wrote an import procedure via data step. data lib.txtimp; %let _EFIERR_=0; infile "file/path/tabdlm.txt" lrecl=256 dlm='09'x missover firstobs=2 DSD; informat…
samkart
  • 6,007
  • 2
  • 14
  • 29
0
votes
1 answer

Is it possible to filter a data step on a newly computed variable?

In a basic data step I'm creating a new variable and I need to filter the dataset based on this new variable. data want; set have; newVariable = 'aaa'; *lots of computations that change newVariable ; *if xxx then newVariable =…
stallingOne
  • 3,633
  • 3
  • 41
  • 63