This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Create label data set; | |
data label_data_set; | |
length name label $25.; | |
name="Sex"; label="Gender"; output; | |
name="height"; label="Height (in)"; output; | |
name="weight"; label="Weight (lbs)"; output; | |
run; | |
*Create sample dataset to apply label; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*path to the zip file; | |
filename src zip "/home/fkhurshed/Demo2/P_DR2IFF.zip"; | |
*path to where to save the xpt file; | |
filename xl "/home/fkhurshed/Demo2/P_DR2IFF.xpt" ; | |
*extract file from zip - P_DR2IFF.XPT in the code below is the name of the file in the zipped file that is to be extracted; | |
data _null_; | |
/* using member syntax here */ | |
infile src(P_DR2IFF.XPT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class; | |
set sashelp.class; | |
length category $20.; | |
bmi = 703*(weight/(height**2)); | |
if bmi < 18 then | |
category='Under Weight'; | |
else if 18 <= BMI < 25 then | |
category='Normal'; | |
else if 25 <= BMI < 30 then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This code will search text files for a single word, search_string | |
Originally via @schmuel here: | |
https://communities.sas.com/t5/Base-SAS-Programming/Searching-SAS-code-for-keywords/m-p/390472#M93671 | |
*/ | |
%let search_string = rename; | |
%let suffix = sas; | |
%let root=/folders/myshortcuts/My_Folders/; | |
filename finp ("&root.sas_help/*.&suffix"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*create sample data for demonstration; | |
data have; | |
infile cards dlm='09'x; | |
input OrgID Product $ States $; | |
cards; | |
1 football DC | |
1 football VA | |
1 football MD | |
2 football CA | |
3 football NV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*Create sample data; | |
data random_sentences; | |
infile cards truncover; | |
informat sentence $256.; | |
input sentence $256.; | |
cards; | |
This is a random sentence | |
This is another random sentence | |
Happy Birthday | |
My job sucks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc sql; | |
create table master_process_time | |
(Entry char(32), | |
StartTime num format=datetime22.4, | |
EndTime num format=datetime22.4, | |
duration num format=32.4, | |
recordTime num format=datetime22.4); | |
quit; | |
%global startTime endTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This program exports all files from a library into CSV files. | |
Author: F. Khurshed | |
Date: 2020-09-25 | |
*/ | |
options dlcreatedir; | |
proc options option=dlcreatedir; | |
run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*https://communities.sas.com/t5/SAS-Programming/combining-multiple-columns/m-p/705769 | |
/*This example illustrates how to combine variables from labels or variable names | |
from a list of indicator variables | |
Author: F. Khurshed | |
Date: 2020-12-14 | |
*/ | |
data have; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*An example/demo of how to convert a macro variable list that is space delimited to comma delimited. | |
%Let weightvar = WEIGHT HEIGHT AGE; | |
*uses the translate function to replace spaces with commas. If VALIDVARNAME=ANY this may not work; | |
%macro addCommas(varList=); | |
%sysfunc(translate(&varList, %str(, ), %str( ))) | |
%mend addCommas; | |
*example recoding; |
NewerOlder