Questions tagged [sas-macro]

A metaprogramming language used in the SAS suite to modify normal SAS code at run-time.

SAS Macro language offers more flexibility for programming SAS code. SAS code written with SAS Macro will be compiled before execution. SAS Macro language uses % for calling SAS macro functions and for calling and defining macros, e.g.:

%macro temp;
  %put %sysfunc(date());
%mend;
%temp;

Variables are used with &, e.g.:

%let my_var = "Hello World";
%put &my_var.;

More about

1265 questions
-1
votes
4 answers

SAS - if and then condition statements

My data is more than 70,000. I have more than 50 variables. (Var1 to Var50). In each variable, there are about about 30 groups (I'll use a to z). I am trying to get a selection of data using if statements. I'd like to select every data with the …
-1
votes
4 answers

How to convert a number to a SAS time value?

I have variable in sas which has reads time as 515(numeric format), however I would like to convert it to appear 5:15 or 05:15. data output; set old; /* if variable name is var, what should I write here to convert 515 to 5:15 or to…
-1
votes
1 answer

appending files in a macro using sas

Actually I have just started learning the SAS and I am not that good in macro. I am working on large data which is divided into different parts for each day. But at the end I have to append them as a single day.The code I have used is- options…
-1
votes
1 answer

Creating a macro to subset a monthly data into smaller datasets based on date in SAS

I'm working on a large dataset which have data for a whole month with around 42 variables, and I want to create separate datasets for every day of the month. How can I create a macro which will do it properly? The date variable is trans_date and…
Jay
  • 1
  • 1
-1
votes
1 answer

sas 9.3 - insert a new line with condition in proc report

I want to insert a new line after a group of every br variable but not when br=10 in proc report. I have the compute code written as below, but the if condition does not seem to work compute after br/ style={borderrightwidth=2 bordertopwidth=1…
sria
  • 35
  • 2
  • 10
-1
votes
2 answers

How to convert SAS E dates into readable dates

Hi I'm working in SAS platform and I've a data_set with more then 30 columns. there are two date columns in that data-set. dates in that data set are in format as 1.33E12 This is the little part of my table I want to create a new data-set with few…
Azeem112
  • 337
  • 1
  • 8
  • 23
-1
votes
1 answer

SAS2XLSX Generated XLSX Under Linux x64 Not Able to Open

I have downloaded SAS2XLSX macro from PhUSEwiki and PhUSE Paper. I run this macro under PC SAS 9.3 x64 and Linux SAS 9.3 x64. But Linux generated XLSX is not working. I need to use it for Linux. I have also compared all individual XML files with PC…
-1
votes
3 answers

SAS program, How to do the calculation based on two tables without IML

I've been struggling with some matrix calculation in sas. I have two tables, which both contain Longitude and Latitude information Tasks table Engineers table: My output goal is the distance between tasks and engineers Distances: Due to the…
ZYJ
  • 57
  • 6
-1
votes
1 answer

Combine different SQL into one table using SAS

I would like to know how to combine different SQL queries into one table. The format should be customer_no|TOTAL_DIFF_LASTPAYMENT_OPENED_dt|utilization trend| count_enquiry_recency_365|ratio_currbalance_creditlimit I have two files with data…
Hani Ihlayyle
  • 135
  • 3
  • 12
-1
votes
1 answer

How to get user properties like created by in sas

How to fetch user details for a .sas file or file properties for all files stored in a directory? I am trying to get all possible attributes like: modified date, modified by, created by, for a macro. data dir_meta(drop=rc file_ref fid); %let…
-1
votes
1 answer

Choose from options based on values from previous rows

** The data is a sample data of 20 orders across a universe of 3 stores.Trying to write an algorithm to identify which store would cater to which order based on the rules ** If there is more than 1 store eligible for an order, the store that has…
user3117837
  • 87
  • 1
  • 8
-1
votes
1 answer

PROC SQL/Variables within SAS Macro being ignored

I have the below macro, PARAMETERS, that assigns values to five variables and creates the table MD_WRK.SUB_ID. My issue is that the code within the macro worked fine until I placed it within the macro. Now the variables are not being populated and…
Matt Dixon
  • 11
  • 4
-1
votes
1 answer

How to reference another table in sas macro

I'm trying to use a parametric table as a sas format. I have tried many ways but any of them works. My ideas are. With a proc format. I am not sure if I can use two specific columns from a dataset to build a SAS format. To build a SAS Macro which…
diagonal
  • 1
  • 1
-1
votes
1 answer

search the library to append data-sets having specific variable

I have 2 datasets in library aa & bb respectively. My code checks first the datasets in the library if they having specific column variables in them. If the datasets have the specific variables then they are appended. But when i run my macro it…
Apache11
  • 189
  • 11
-1
votes
1 answer

I want to creat a macro to loop through Year, Quarter, Month and column value

SAS Question: I have a table having one column named: Primary_coverage having 4 observation as shown below, Primary_coverage combined single limit uninsured motorist Medical Bodily Injury I want to create a macro to loop through Year, Quarter,…
Subrat Swain
  • 11
  • 1
  • 2