PROJECTS NOTES HOME

Sas commands

1 SAS oracle conenction string(libname)

libname TESTS oracle path="BIXXXP1" schema="XXX_DST"
user="XXX_BATCH[XXX_DST]" pw="password" DB_LENGTH_SEMANTICS_BYTE=NO
DBCLIENT_MAX_BYTES=1 encoding='utf-8';

2 Map library

No second quotes!

libname out '/home/s2753g;

3 Find current user name

%put &SYSUSERID;

4 Check SAS Viya license

proc setinit;

5 Find ALL information about a library

List the library path for a specific library.

proc contents data=SEB_RDD._all_;
run;

6 Compare contents of the table

Library.Table

proc compare
	base=Scratch.H_XXX_1
	compare=Back_L.H_XXX_1
	novalues;
run;
data XXX_TEST;
set SEB_RDD.XXX_TEST (where=(TIME_PERDIOD = 202310));
run;

data XXX_TEST2;
set SEB_RDD2.XXX_TEST (where=(TIME_PERDIOD = 202310));
run;

proc compare
    base=XXX_TEST
    compare=XXX_TEST2;
run;

7 Compare two tables from different schemas

proc compare base=YOUR_BANK.POSTAL compare=YOUR_BANK2.POSTAL out=comparison_result outnoequal;
id POSTNUMMER;  /* Specify a common key to match rows */
run;

8 Copy table from one schema to another

data work.POSTAL;
set your_bank.POSTAL;
run;

data 2.POSTAL;
set your_bank.POSTAL;
run;

9 Check lengths and encoding

[2023-10-19 Thu] meeting with A and SAS Support.

data x;
length a $3;
a="abc";
output;
a="sjö";
output;
a="åöä";
output;
run;

10 Include external file

Physical on the server

%macro test_weight_control;
   %put Hello, World;
   %let x = 5;
%mend;
%include 'test_weight_control.sas';

%test_load_control;

%put The value of x is &x;

11 Include internal file

In SAS Viya

filename sasFile filesrvc folderPath = '/Jobs/YES' name='test_work_control.sas';
%include sasFile / source2;
filename sasFile clear;

%test_work_control;

12 Encode a password

proc pwencode in='my password';
run;

13 count all rows in a table

proc sql;
    select count(*) as TotalRows
    from SCHEMA.POINTS_D_XXX;
quit;