Friday, July 7, 2017

How to extract filename and extension from the absolute path in SAS


This is very simple problem in SAS, but somewhat nowhere on internet written. You can use scan function to catch last occurrence of string.
%let infile=/sadare/sads/adas/filename.extension;
data test;
  source=scan("&infile.",-1,"/");
run;

Friday, October 28, 2016

How to set special characters in SAS Base code

If you ever end up having a sas variable, which contains special characters in it, and you want to split them into each separate variable, you need to use a ascii number equivalent to required special character,and at x at the end of the string.
For example, if the special character is tabulator:

data test;
a="column1 column2 column3"; column1=scan(a,1,'09'x); column2=scan(a,2,'09'x); column3=scan(a,3,'09'x); run; In ASCII table, '09'x is a ascii equivalent to tab character.

Saturday, October 22, 2016

How to round the number up to 2 digits in Javascript

Sometimes you need to round up the number up to 2 digits. For example, you calculation has to show a result in currency.

There are two solutions to use on internet:

1) Use Math.random function.

var a=123.4567;

Math.random(a*100)/100

However, this is not really good, as for example in case of
var a=1.005;
Math.random(a*100)/100 results into 1 instead of 1.01.

2) use toFixed(2)

However, it is more secure option to use a.toFixed(2), which would return element as fixed 2 decimal value

Friday, January 15, 2016

How to download/upload a SAS dataset from server to your local machine

There is a neat way the EG offers you to download SAS datasets.
Under a menu bar, there are a options

  • "Tasks" - "Data" - "Upload Data Files to Server" and 
  •  "Tasks" - "Data" - "Download Data Files to PC" 
In case of "Download Data Files to PC", you need to choose a dataset you want to transfer.

My humble suggestion is to first subset the original dataset to a temporal dataset you exactly need, and download only the temporal dataset.


Detailed screenshots will follow...

Thursday, October 22, 2015

Changing system time on Virtual Box Virtual machines


Once upon a time I needed to change the system time of the virtual machine to test its behavior at specific date/time. To do that, you can use the following commands:
VBoxManage setextradata "YOURVIRTUALMACHIENNAME" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1
VBoxManage modifyvm "YOURVIRTUALMACHIENNAME" --biossystemtimeoffset -36288000000
This script above returns the time 420 days in the past. Note to myself: Change this post to add also other useful commands, including the one to switch existing virtual hard disk properties (static to dynamic, its size, etc)

Monday, October 19, 2015

Javascript - Take care of Regular Expressions

These text here is my summary of things I learned while reading the eloquentJS book. In order to understand the issues mentioned in a book better, I have created a different examples.

Take care when using Regular expressions in Javascript.


1) lastIndex is not refreshed, when using global regular expressions for multiple exec calls.

var whitespace = /\s/g;
var test1="This is the first test";
var test2="This is the second test";
var test3="This is the third test";
var test4="This is the fourth test";

whitespace.exec(test1);
document.getElementById("result").innerHTML="after test1:"+whitespace.lastIndex;
whitespace.exec(test2);
document.getElementById("result").innerHTML+="
after test2:"+whitespace.lastIndex;
whitespace.exec(test3);
document.getElementById("result").innerHTML+="
after test3:"+whitespace.lastIndex;
whitespace.exec(test4);
document.getElementById("result").innerHTML+="
after test4:"+whitespace.lastIndex;

Thursday, October 8, 2015

SymbolHound

It often happens to me that I have a part of a code which I dont understand, neither know how to search for it.
These cases are those when you look for some operator shortcuts in programming codes.
For example, (+) sign in PL/SQL. How to find this?
Through answers of good old StackOverflow community, I came up to symbolhound .
Perfect search engine for exactly those cases!