sas MACRO ampersand

With a single set of ampersands, what you get is pretty boring; after one, odd number of ampersands leads to resolving twice, even number of ampersands resolves once. So you use 1 ampersand to resolve once and 3 ampersands to resolve twice, unless you have stock in the company that owns rights to the ampersand. … Read more

Dynamically call macro from sas data step

This in part depends on what your macro is doing. If we assume that your macro is doing something that is intended to be run outside of a data step (ie, it’s not just assigning a data step variable), then you have several options. CALL EXECUTE PROC SQL: SELECT INTO macro variable Write macro calls … Read more

Large, persistent DataFrame in pandas

Wes is of course right! I’m just chiming in to provide a little more complete example code. I had the same issue with a 129 Mb file, which was solved by: import pandas as pd tp = pd.read_csv(‘large_dataset.csv’, iterator=True, chunksize=1000) # gives TextFileReader, which is iterable with chunks of 1000 rows. df = pd.concat(tp, ignore_index=True) … Read more

Why won’t my macro variable resolve?

Macro variables in SAS won’t resolve when they are in single quotes, ‘&myvar’. They need to be in double quotes, “&myvar”, in order to resolve properly. If you need to have single quotes and a resolved macro variable, you have a few options, but the simplest is: %str(%’&myvar.%’) The %’ inside of %str will place … Read more

Nested ifelse statement

If you are using any spreadsheet application there is a basic function if() with syntax: if(<condition>, <yes>, <no>) Syntax is exactly the same for ifelse() in R: ifelse(<condition>, <yes>, <no>) The only difference to if() in spreadsheet application is that R ifelse() is vectorized (takes vectors as input and return vector on output). Consider the … Read more