Here's a SAS macro to Create and Remove a PC Directory... Often we ignore Notes and warning in the SAS log when
we try to create/remove a directory that does/doesn't exist...This macro first checks for the existence of the directory and
then create/delete it or else put a message to the SAS log...try it out :-)
Well...there are many ways of getting the observation count into a macro variable...but there a few pros and cons in those
methods...
2. datastep
eg.
data new;
set old nobs=num;
call symputx('macvar',num);
run;
Suppose there was a large dataset....This SAS macro program splits the dataset by the number of observations
mentioned...
macro name
%split(DatasetName, No ofobservation to split by)
%macro split(dsn,splitby);
data _null_;
set &dsn nobs=num;
Here's a macro for you to achieve it...For example I've used a dataset sashelp.flags and created some more variables
with variety of variables with names upper / lower cases and _'s to demonstrate the reorder macro....
Please try this macro for yourself and let me know your suggestions....
data flags;
set sashelp.flags;
a=2;
b=4;
You might think I am crazy...but I have been using this macro for a long time to fix some contacts in my Google
Contacts...I get a little irritated when I can't find a particular person by email...so I wrote this macro...
This macro takes for Input a .csv file that is exported from Google Contacts and outputs a file that is ready to be imported
to Google Contacts....often I wanted to have Names in the proper case...
%macro organizeGoogleContacts(infile,outfile);
/*Import your contacts into SAS */
data googlegroups;
infile "&infile" dlm=',' dsd lrecl=32767 firstobs=2;
A document that discusses SAS Macro to Create a delimited text file from a SAS data set..
options mprint;
data one;
input id name :$20. amount ;
date=today();
format amount dollar10.2
date mmddyy10.;
label id="Customer ID Number";
datalines;
1 Grant 57.23
2 Michael 45.68
3 Tammy 53.21
;
This macro splits a dataset to multiple datasets vertically with a common primary key. For eg, a dataset has 400 fields and
20,000 records. If we can split the dataset into two, with 200 fields and 20,000 records in each dataset with a common
field like loan number as primary key would be helpful to load the details for analysis.
/**
To be called like this...
%splitdsnverticallykey(dsn,varperdsn,keyvars=);
eg. %splitdsnverticallykey(sashelp.vtable,4,keyvars=memname libname);
Where -----------
Here's a macro that reads the filenames available at a particular directory on any FTP server (i.e. Windows Network
Drive/Unix/Mainframe)...