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
1 answer

Efficiently reformat data layout

I have several Excel spreadsheets with data layout like this raw data: company company1 company2 company3 currency $ Y E 1/1/2013 32.68 12 3 1/2/2013 12.5 13 4 1/3/2013 45 45 …
Xinxin Li
  • 51
  • 1
  • 1
  • 9
-1
votes
2 answers

Checking the existence of a variable in SAS code

I am not sure if I get any answer on a saturday evening, but I will give a shout :) I am trying to automize a SAS-code which does comparison in a viariable between 2-3 companies. In each task, I will probably work with different companies, so I…
user3714330
  • 679
  • 12
  • 32
-2
votes
1 answer

Code missing datalines as unknown instead of missing

I am trying to recode the missing frequency counts to unknown and have 0 missing and place them in the unknown category instead. My code does not produce errors but it does not recode them as unknown I tried using if/then statements to recategorize
angel
  • 1
-2
votes
1 answer

What is the python equivalent of %if, %eval, %do, and %put in sas sql macros?

I am trying to convert the following code from sql to python: Sql code: %macro extract(custom_nm= ); %if %eval(&custom_nm. ne ) %then %do; %put ------ ABCD ABCD ------ ; %end; Converted python code: def extract(custom_nm): I haven't…
-2
votes
1 answer

how can i output all designed data set from one lib

develop a macro that will access a library called "test" and pull 100 records from the tables as long as the table name started with "math_" please offer as much detail as you can. thank you
beibei
  • 9
-2
votes
2 answers

how to replace string

if column 'all' contains the string which is in column 'sch', then this string will be replaced by the string in 'rep'. the column 'new_all' is what I expected. data a0; input sch $9. rep $14. ; cards; map_clm map_claim xyz_ttt xyz drug_clm…
Jeff
  • 29
  • 6
-2
votes
4 answers

List of special characters in SAS macros

I'd like to know which characters are safe for any use in SAS macros. So what I mean by special characters here is any character (or group of characters) that can have a specific role in SAS in any context. I'm not that interested in keywords (made…
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
-2
votes
1 answer

Wanna know how to implement %input in SAS Macros?

Can some one help me in using %input macro statement in SAS. I came to know by googling, that %input is a macro statement used to create macro variables.
Saran
  • 79
  • 1
  • 8
-2
votes
1 answer

proc report to display dynamically

proc report to dynamically display report using macros 1.selection criteria dynamically ex:city=Atlanta, Washington 2.dynamically pick the variables(columns) to display 3.dynamically display total
rocky
  • 1
  • 1
  • 1
-2
votes
2 answers

how can i create loop in SAS using iterative method and print the results

i would like to make an iterative loop in SAS to calculate the average for each id my data as follow : data sample
-2
votes
1 answer

SAS PROC export to excel and save format

I have SAS guide output. I want to PROC export him, the problem is that when i export him to excel All the format changes. When I use in the SAS guide the "export as step in the..." everything is ok. But I need the PROC export So , how can I …
itamar
  • 1
  • 1
  • 1
-2
votes
1 answer

SAS macro variable will not resolve

Try again. This code will not work. It is a stupid code but still do not work. data work.colnames; input cols $; cards; U1 B1 ; run; data work.test; input rp_U1 $ rp_B1 $; cards; col1 col2 …
fossekall
  • 521
  • 1
  • 10
  • 27
-2
votes
1 answer

DS having multiple variable in a specific library append them

%macro chk(lib=,varlist=); proc sql noprint; select distinct catx(".",libname,memname) into : datalist separated by " " from dictionary.columns where libname = %upcase("&lib") and %upcase(&varlist) = upcase("&varlist"); quit; data…
Apache11
  • 189
  • 11
-2
votes
1 answer

SAS macro which will generate the PDF/Excel/RTF report from the input SAS dataset

need GENERIC SAS macro TO generate the PDF/Excel/RTF report from the input SAS dataset. THE FOLLOWING are the parameters to use----> 1) indsn – Input Dataset 2) varlist – List of Variables to be printed. If none then print all variables in the…
Apache11
  • 189
  • 11
-2
votes
1 answer

sas generate 5 digit id code that first 3 must be letters and last 2 numbers

How can I generate in SAS and ID code with 5 digits(letters & Numbers)? Where the first 3 must be letters and last 2 must be numbers.
zak
  • 1
  • 1
1 2 3
84
85