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
1
vote
3 answers

SAS DATA STEP WHERE CONDITION IN A LIST

I tried to filter data where they are on a list by using Data step in SAS proc sql; create table id_list as select distinct id from customer; quit; data test; set fulldata; where id in id_list; run; It doesnt work. However, if I use "where id in…
Linh
  • 13
  • 3
1
vote
1 answer

How to make a table (with proc report or data step) of a grouped variable where in different columns are counts of different variables?

Could you give some advise please how to calculate different counts to different columns when we group a certain variable with proc report (if it is possible with it)? I copy here an example and the solution to better understand what i want to…
1
vote
3 answers

Compare data from different data sets SAS

I have two tables table_A and table_B. table_A Queue_nm Cust_nm ABCD VERI PQRS RSTQ table_B Queue_nm Act_Cust_nm PQRS TMOB I want to compare the two datasets and if they don't match, then replace the data in table_B in…
Rogue258
  • 109
  • 1
  • 9
1
vote
0 answers

get the first day of each month between two dates in python

I would like to perform a cycle between two dates considering only the first day of each month between the selected dates. My starting point is the following script: import datetime start_date = datetime.date(2020, 1, 1) end_date =…
diedro
  • 511
  • 1
  • 3
  • 15
1
vote
1 answer

Macro execution inside data step

I have the following macro which I will use inside a data step: %global var3; %macro add(var1,var2); %let var3 = %eval(&var1+&var2); %mend; I don't understand the results of the following data step: %let var3 = 2; data test; put "The…
treskov
  • 328
  • 1
  • 4
  • 17
1
vote
1 answer

Nesting a SAS macro in a macro to process a subset of items

I have a set of csv files named m6.csv through m22.csv, where the number in the file name increments by 1 with each new file. All data sets have a variable called passedchecks, but in only some of the data sets is it useful. I would like to subset…
J.Q
  • 971
  • 1
  • 14
  • 29
1
vote
1 answer

how to join two datasets and update one column values only not affects other columns in sas?

this is a sample datasets need to be update one columns only .same columns name but different values add only like age in first ds. data step or proc sql; common values dob and name Please help me thanks first data set data sql; input name $4. age…
1
vote
1 answer

Assiging the same value for another column

I have a task in SAS; What I need to do is to assign the October Current_value (60) in the column Fake_1 and let repeat it only for the months of October, November and December; the same logic should be applied to valorise column Fake_2, and assign…
Enrico
  • 53
  • 6
1
vote
1 answer

Importing large XML file into SAS

I have a 5GB size XML data file and I need that imported to SAS. I am trying using libname and its still running and running libname in xml 'C:\Test\Datafile.xml'; data want; set in.want; run; Is there a better way to…
ckp
  • 579
  • 2
  • 10
  • 27
1
vote
3 answers

SAS: binning data

data scores; length variables $ 16; input variables $ low high score; datalines; Debt -10000 1 55 Debt 1 10000 23 MAX_NA -1 1 500 MAX_NA 1 100 -240 ; data main_data; input ID Debt MAX_NA; datalines; 222554 7584 12 …
Loncar
  • 125
  • 8
1
vote
5 answers

SAS-Append data to a table and increment a flag on the resultant table

I have two tables on SAS "Table_A" and "Table_A_Archive", as part my ETL process "Table_A" is created on a daily basis and the data should be archived on "Table_A_Archive". When the data is archived on "Table_A_Archive" a a flag will be…
Sudhan
  • 287
  • 2
  • 5
  • 11
1
vote
1 answer

SAS: multiply rows according to value

I have the following sample data frame: DATA queries; INPUT id :$12. type :$3000. count :3.; INFILE DATALINES DSD; DATALINES; 1, Theft, 3 2, Assault, 3 3, Murder, 1 4, Fraud, 1 ; RUN; But I'd rather have each row repeated n times (according to the…
D. Studer
  • 1,711
  • 1
  • 16
  • 35
1
vote
3 answers

Calculate growth rates for several variables at the same time

I would like to calculate the growth rate of several variables without doing it manually. Is there any smart way to do it? E.g. See table below from sashelp.citiyr that looks like: DATE PAN PAN17 PAN18 PANF PANM 1980 227757 172456 …
user3507584
  • 3,246
  • 5
  • 42
  • 66
1
vote
1 answer

How Can I Stop a SAS Data Step from Opening a Command Prompt

I've successfully executed a call to Python code in my SAS interface, thanks to you lovely folks in the land of Stackoverflow.com. My next question is this: When my data step calls the code, I get a command window that opens up, but nothing appears…
1
vote
2 answers

Create a table with column name values available in a different table

SAS Datastep- Create a table dynamically with the column name values available in a different table. Example: My Source_Table would look like |Field No|Field Name| |1| A| |3| B| |2| C| /*Dynamic table creation*/ %let s1=; /*Column lenght should be…
Sudhan
  • 287
  • 2
  • 5
  • 11