sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
d9abb4383cdc1ad82b6d96f171491f614fef6d32211c325e7e63b88a7d242e82
SAS
3,066
86
%macro MakeCMapSimilarityScoreBarplot(cmap_similarity_score_file); /*proc import datafile='/home/cheng.zhong.shan/data/MAP3K19_down_regulated_genes_drug_similarity_scores.txt'*/ proc import datafile="&cmap_similarity_score_file" dbms=tab out=x replace; run; data x;set x; /* where abs(score)>95 and type="cc" and n...
e3e4ca58cd116e46711defe5fcc3bb45bebbb603c41e60681f9370951376b847
SAS
3,078
111
%macro DiffTwoCorrelatedGWAS(/*Note: only common SNPs will be kept*/ gwas1dsd=, gwas2dsd=, nctrl=,/*Number of samples for the common grp between gwas1 and gwas2*/ ngwas1=,/*Total sample size for gwas1*/ ngwas2=,/*Total sample size for gwas2*/ gwas1chr_var=, gwas1pos_var=, snp_varname=rsid, beta_varname=beta, se_varnam...
cd6397e5d227a1c59b006edf6f450241751dc1ab0c3e36ffb09e3155a5cd0e4f
SAS
3,088
124
%macro RiskFactorAnalysis(dsd,pheno,age_var,tested_vars,fisher); %let test=chisq; %if &fisher=1 %then %let test=fisher; proc sort data=&dsd;by &pheno;run; proc print data=&dsd (obs=10);run; proc univariate data=&dsd normal plot; var &age_var; histogram &age_var/normal (MU=EST sigma=est color=red l=1); by &phe...
4a0518215d2e6fce25e16c7dd01c47fa3b9e894e414593c6ef275a0eb61a7f30
SAS
3,118
90
%macro is_sas_macro(file=, bytes=8192, mv=IS_SASMACRO); %if "%sysfunc(strip(&file))" ="" %then %do; %put ERROR: (is_sas_macro) FILE= must be specified.; %return; %end; %global &mv; %let _exists = %sysfunc(fileexist(%sysfunc(dequote(&file)))); %if &_exists = 0 %then %do; ...
8ba0cee9eca69813bec694de14ef94e553ae0b2e9d42cb581fa876b836322ec3
SAS
3,125
107
%macro Import_UKB_GWAS( ukb_file=both_sexes.INFLUENZA_All_influenza_not_pneumonia_,/*for gz file, need to provide fullpath*/ dsdout=x, deleteZIP=0, print_top_hits=0 ); /*data x;*/ /*infile 'both_sexes.INFLUENZA_All_influenza_not_pneumonia_' dsd lrecl=32767 dlm='09'x truncover firstobs=2 obs=max;*/ /**Need to provide ...
5516d4a053779f5ecd54b4cfab4e45bf866a9ba32f273370bee04374acecfff2
SAS
3,148
106
%macro get_HGI_covid_gwas_from_HGI( gwas_url, outdsd, for_subpop=0 /*R7 GWAS for ALL and sub-populations are in different format*/ ); %let wkdir=%sysfunc(getoption(work)); %let gwas_gz_file=%sysfunc(prxchange(s/.*\///,-1,&gwas_url)); %dwn_http_file(httpfile_url=&gwas_url,outfile=&gwas_gz_file,outdir=&wkdir); /*...
115706daf9a89470f4fca859d2a7db949c366263191c382af01c4828e3607e5d
SAS
3,152
107
%macro Make_Proc_Import_Code(abs_data_file_name,sas_code_file,kept_variables,getnames_yes_no,datarow,dbms,Force2Num,dsdoutname); *Excape char '\' or '/' in abs_data_file_name; %let abs_data_file_name=%sysfunc(prxchange(s/[\\\/]/\\\//,-1,&abs_data_file_name)); %put &abs_data_file_name; proc printto log="SAS_...
dee34aaa7f932764aa065051f4a48c5dcf01d3574da0af7301930f280a3a4370
SAS
3,200
142
%macro deseq_normalization4longdsd( indsd=a, outdsd=z, key4row=r, key4col=c, val_var=val ); data &indsd; set &indsd; /* if &val_var=0 then &val_var=.; */ if &val_var=0 then delete; run; *get geomean; proc sql; create table row_geomean as select distinct &key4row, exp(mean(log(&val_var))) as geo_mean fr...
70de9e33ede056af57a462786cf01821d8598ee3adaa7b14deb717c34a038fe9
SAS
3,224
108
%macro QueryRangeDsd(base_dsd, key4range_in_base, st4range_in_base, end4range_in_base, extra_vars_in_base2keep, query_dsd, key4range_in_query_dsd, Pos4lookup_in_query_dsd, ou...
9300d42a374f2679fc3c289256beed4d7d5a245b4d098a14de91a3d807949784
SAS
3,227
101
%macro transpose_rows2cols4table( /* Transpose rows-to-columns for a table; Creates a mapping dataset (mapout) that stores long original &by values for each short column id; Note: long2wide4multigrpsSameTypeVars is better than this one for handling column names with length >32; */ data=, out=, by=rowlabels, var=_...
5c6a07db1eee4484fbf24cfaa344da4343e08e5ffb8df3cc0e95ac7835673b9d
SAS
3,243
120
%macro get_UKB_gwas_from_UKB_old(gwas_url,outdsd); %let wkdir=%sysfunc(getoption(work)); %let gwas_gz_file=%sysfunc(prxchange(s/.*\///,-1,&gwas_url)); %dwn_http_file(httpfile_url=&gwas_url,outfile=&gwas_gz_file,outdir=&wkdir); /*Put tmp data into sas work directory will save space*/ /* %ImportTXTFromZIP(zip=&wkdir...
306f7e761a8e10f3ef2dc69b390bfecce98859ed8aaee7f628121101b33c9e8c
SAS
3,316
97
%macro PlotGeneTrackWithoutScatterplot( gtf_dsd=FM.GTF_HG19, /*demo for MAP3K19*/ chr=2, minst=135023787, maxend=137000000, dist2genes=0,/*use it get SNPs located beyound the regions with the dist*/ dist2st_and_end=50000,/*to make the gene track to extend the regions beyound the gene st and end*/ design_width=1000, des...
f6a9cbe8430b883b6556709673418213c80aadc078821b7679ff1d4504d80eab
SAS
3,324
104
%macro hist4p(dsdin,pvarname=pval,pbins=0 1e-7 1e-5 1e-3 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1,pgrp=g,outdsd=summary); %make_bin_format(bins=&pbins,out_format_name=Pfrt); data X; set X; P=&pvarname+0; %if &pgrp ne %then %do; G=&pgrp; %end; run; proc freq data=X; %if &pgrp eq %then %do; table P/out=&outds...
8b8ed93a1273499a6279b4c93d8f68bf0220d33ec4352d9a9f4232499e7bc948
SAS
3,388
125
%macro plot_bed_with_gene_exons4dsd( bed_dsd=, gene_exon_bed_dsd=, dist2st_and_end=50000, design_width=1000, design_height=200, barthickness=20); /*proc print data=_last_(obs=10);run;*/ /* %chr_format_exchanger( dsdin=_last_, char2num=1, chr_var=chr, dsdout=a1); */ /*%chr_format_exchanger( dsdin...
3a056f5660f2614402a9f240656fba3660e58ce5043fa70798bdbacf9e47663e
SAS
3,392
93
%macro random_import_cell_mtex_slow( gzfile=,/*the fullpath to compressed or plain file, such as gz, txt, zip, and others.*/ max_colnum=1000000,/*If the max number of cells to read from each line >10000, it will take too much time*/ totrandom_cols=10000, random_seed=2718, outdsd=subset_cell_exp, rowname_len=100, ...
255a6acc91399740eafe57fa019443e026fed532644081545184250ff86e2a79
SAS
3,432
162
%macro list_ORA(/*Over-representation analysis*/ base_list_dsd=, /*A data set containing lists of elements associated with specific sets or pathways*/ base_list_var=V1, query_list_dsd=, /*Target elements for testing enrichment of elements from the base_list_dsd in the ref_list dsd*/ query_list_var=V1, ref_list_dsd...
9cb2f16cb45396f60e557c4e858d883462311b39449f5487e207d9cf27051fde
SAS
3,457
141
%macro fisher4cntdsd(dsn=, case1var=, case0var=, ctr1var=, ctr0var=, byvars=, outdsd=); data &outdsd; set &dsn; caseWMutation=&case1var; if caseWMutation=. then caseWMutation=0; caseWOMutation=&case0var; if caseWOMutation=. then caseWOMutation=0; controlWMutation=&ctr1var; if controlWMutation=. then controlWMutation=0;...
1b6a0ff7e34927e3792b1de76d104904e9007f62208ce854551bd649fd679026
SAS
3,483
132
%macro gscatter_with_gene_exons4dsd( bed_dsd=, yval_var=, scatter_grp_var=, gene_exon_bed_dsd=, dist2st_and_end=50000, design_width=1000, design_height=200, barthickness=20); /*proc print data=_last_(obs=10);run;*/ *Note: both the bed_dsd and gene_exon_bed_dsd should have char chromosomes; /* %chr_format_exchanger(...
7a04993d497673aa6fa3c64c7166bb3c237ae82ca58bd134a9330f5aceb40d03
SAS
3,505
94
/********************************************************************** Parameters: root_path - All directories and files under this root will be deleted. The root_path will not be deleted (just empty) lev - Used by the recursion algorithm, no need to modify default rmFiles_lev0 - Set t...
b15aba85d63ac8cb5a393062d7f63c3c6739a308b459c681348dc6bf996d3152
SAS
3,546
98
%macro random_import_cell_mtex2longdsd( gzfile=,/*the fullpath to compressed or plain file, such as gz, txt, zip, and others.*/ max_colnum=1000000,/*If the max number of cells to read from each line >10000, it will take too much time*/ totrandom_cols=10000, random_seed=2718, outdsd=subset_cell_exp, rowname_len=10...
d3db62b02f2502027f8d3677f127969834cdafe8b31810eca96b04427f35a83b
SAS
3,547
129
%macro plot_scatter_with_gene_exons4dsd( bed_dsd=, yval_var=, gene_exon_bed_dsd=, dist2st_and_end=50000, design_width=1000, design_height=200, barthickness=20); /*proc print data=_last_(obs=10);run;*/ *Note: both the bed_dsd and gene_exon_bed_dsd should have char chromosomes; /* %chr_format_exchanger...
68a1699d5a9ff7b19591183906366b95466e8b9f61298d4d5cd1aa8049d75dad
SAS
3,556
122
%macro Extract1KG_Genos( OneKG_Path,/*Use forward slish and No slish at the end*/ maf, SubsetSamplesFile, Outdir /*Use forward slish and No slish at the end*/ ); %get_filenames(location=&OneKG_Path,dsd_out=OneKG_filenames); x cd "&Outdir"; data OneKG_filenames; set OneKG_filenames(where=(memname conta...
6938696e592621950b76c5c0acdbd4f4fdf0b4557f4a8f002341620156c38deb
SAS
3,599
121
%macro merge_dsd_by_comm_vars(dsds=, /*Name of the datasets, separated by space */ out=, /*Name of combined data set */ comm_vars_rgx= /*Common vars regulary expression among these datasets; no '()' is allowed!*/); %let commvar_length=8;...
2f7b89d472afd15a5aa71adc4588b1242e8120f4fd1b426856994004454cb184
SAS
3,613
177
%macro get_top_hits4Manhattan( dsdin=_last_, snp_var=rsid, chr_var=chr, pos_var=pos, p_var=p, dsdout=tophits, p_thrsd=1e-5, /*Only keep these signals with smaller values than the threshold*/ dist4get_uniq_top_hit=1e6 /*Only get the top one hit among the distance by pos with the top one at the center*/ ); *Not...
55123695a125f3663910072bed6168c12dcdc4dfbbf80859674cc142a69ad1fd
SAS
3,624
158
%macro mkfmt4grps_by_var( grpdsd, grp_var, by_var,/*Empty value is possible for this var, which is handy when there would be duplciates of grp_var after sorting by grp_var and by_var for the by_var to make a new format*/ outfmt4numgrps, outfmt4chargrps, dsd4fmt=dsd4fmt /*This dataset can be used to get fmt in...
cc114f02f65a8c6927b7491ed13ed67fca108e57d3c2df8d89dddb3f48d3e735
SAS
3,645
145
%macro makefile ( dataset=_last_ , /* Dataset to write */ filename=print , /* File to write to */ dlmr="," , /* Delimiter between values */ qtes="no" , /* Should SAS quote all character variables? */ header="no" , /* Do you want a header line w/ column names? */ la...
74a52c6ba3e771a54ddf5b6cfa04e251d828af8ed3329add4537efc04d34e335
SAS
3,689
125
%macro plot_bed_regs_with_gene_exons( bed_dsd=, gene_exon_bed_file=, dist2st_and_end=50000, design_width=1000, design_height=200, barthickness=20); proc import datafile="&gene_exon_bed_file" dbms=tab out=exon_info replace; getnames=no; guessingrows=10000; run; /*proc print data=_last_(obs=10);run;*/ /* ...
8633f303a902bcfec9aedf33d97aad992c92baa5a23b1df9c9cce6c2e9e4b8b6
SAS
3,699
120
%macro bed_region_cnv_plot_sep_by_grp(bed_dsd,chr_var,st_var,end_var,grp_var,cnv_var,linethickness=20); /*Note: this macro will create a var ord for making seriesplot and color each bed regions by the macro var grp_var. The limitation is that each bed region will be plotted separatedly among different subplots via...
4c8395931b14c48d64de8f0c342e24c06e13ffb090f00d04e78257d9fa8185b5
SAS
3,718
167
%macro get_top_signal_within_dist( dsdin=, grp_var=, signal_var=, select_smallest_signal=1, pos_var=, pos_dist_thrshd=, dsdout=, signal_thrshd=1 /*filter the input dsdin by association P, i.e, &signal_val <= &signal_thrshd*/ ); data &dsdout; length Key $200.; set &dsdin; dis_st=&pos_var-&pos_dist_thrshd*...
f74cf02f6ac856acf95f4746a08291f9d7bd583e00acb344f86dd52b19c8f195
SAS
3,740
148
%macro barplots_with_refline( dsdin, yaxis_var, errorbar_length=1, bar_width=5, errorbar_color=blue, bar_color=lightblue, grp_var=, sort_bar_var_by_mean=1,/*If value is 0, it will sort by grp_var alphabetically*/ yaxis_label=Mean of target variable ); /*The following script will draw bar plot for your data...
3ebbe7e72a8aa623c03dd30ca75c23d4320af32854591692e4139e56427ac192
SAS
3,756
118
%macro VCF2KggPED( dir= /* Windows path of directory to vcf files */ , filename= /* Single VCF file name */ , dsdout= /* file name used for sas dataset and Kggseq PED file name (under &dir)*/ ...
ff055056fb177d6579978f05345e388a0761caf9f9a607b8efef1d5872f8dab2
SAS
3,789
145
%macro format_xaxis_with_numeric_order( dsdin, Xaxis_vars, new_Xaxis_var, Var4sorting_Xaxis, function4sorting, descending_or_not, dsdout, createdfmtname, KeyVar4Xaxis_vars=KeyVar4dsdout ); *If AlsoAppFun4Cols=1, will apply specific function on each row or ALL Rows (if row_keys is missing) for ALL these mat...
9095823fb457bee3b632b29652a336e617091c161a8d65e4f3db105381c80c15
SAS
3,838
111
%macro sparse_mut_tb2full_long_tb( /* The macro is able to merge a full table with at least one variable, i.e., sample id, with the other smaller table only containing observed muts in samples along with its membership by grp_var4mut, the macro will first create a cross join table between the fulltable and the m...
466f503741f83d6339769e00fec83d24ef98b636bd6057d64127f630002d8a1b
SAS
3,909
164
%macro importfilewithlongheader( filename, dlm4file, startrow4read, headerrow, outdsd, debug); /*%let filename=FB63912.csv;*/ /*%let dlm4file=',';*/ /*%let startrow4read=2;*/ /*%let headerrow=1;*/ /**/ /*Import data without header*/ %if &debug=1 %then %do; options obs=10; %end; proc import dat...
8157a1dffd5fdeacb80e85f18261eb2d9f5592eef0f0f51f9f583a52ade80cee
SAS
3,924
164
%macro check_header_and_values( input_dsd_or_file_or_url=, tgt_var_from_dsd=info, linesep=\t, dsdout=x, column_len=500, header_line=1, value_line=10, use_zcat=0, deleteZIP=0 ); %let wkdir=%sysfunc(getoption(work)); ***************************************Prepare dsd from gz, zip, dsd, or url*************; ...
e96b93cf54b16a57012abe0fdbaa897bdd415376ef6238b686dfd3425da441c3
SAS
3,944
96
%macro DirRecursiveSearch(/*It will use SAS internal functions to search dir recursively*/ root_path=_NONE_,/*All dirs under it will be searched recursively*/ lev=0, SR_Files_lev0=Y ); /********************************************************************** Parameters: root_path - All directories and files ...
6a87a31fa06eaecf46b47da93e50baa6aafd7c5a2b1ca29aba6f13c694002c73
SAS
3,963
178
%macro MergerOverlappedRegInBed( /*Note: the input vars, including chr_var, st_var, and end_var should be numeric;*/ bedin, chr_var, st_var, end_var, bedout, add_original_bed=1, /*if value is 1, the output bedout will merge the original bedin with the newly merged bed regions for these input bed regions*/ dist2...
812c30d626ed49e1f2e7b34ce5d345f741706513c10441e328372b03ad857ac5
SAS
3,988
153
%macro macroparas4hpc( macrorgx=., dir=%sysfunc(pathname(HOME))/Macros ~/shared/Macros /home/zcheng/SAS-Useful-Codes/Macros F:/360yunpan/SASCodesLibrary/SAS-Useful-Codes/Macros /home/zhongshan/SAS-Useful-Codes/Macros H:\F_Queens\360yunpan\SASCodesLibrary\SAS-Useful-Codes\Macros , verbose=0, IsSASOnDemand=0,...
a12b68f9f6c5869ee0156137781cc60266e5422750be9be0da5b0adeeefbcda8
SAS
4,005
180
%macro get_tgt_hits4Manhattan(/*Note: the macro is able to keep the order of target snps and generate a macro var called _chr_colors_ according to the chromsomes that these input snps residing in!*/ dsdin=_last_, snp_var=rsid, chr_var=chr, pos_var=pos, p_var=p, dsdout=tophits, target_snps=rs2564978 rs17425819, ...
6032424c4bac2b87b8ca15e8fa0c18ef0e16f6c0d14f1cb2ecefb45cd45d30c6
SAS
4,009
119
%macro top_gwas_hits_and_nearby_sigs( GWAS_SAS_DSD=, Marker_Col_Name=, Marker_Pos_Col_Name=, Xaxis_Col_Name=, Yaxis_Col_Name=, GWAS_dsdout=, gwas_thrsd=, /*-log10(P) threshold, such as 5*/ Mb_SNPs_Nearby=,/*this Mb_factor will multiple 1,000,000 when running in the program*/ design_width=1000, design_height=200 ); %...
4b841628b7a89eedcff71357a95c92a573da0ee07d1872712cc41ff8e644ccde
SAS
4,035
99
%macro nums_in_range_adj_scale( /*Note: the scale can only be integer with value >=1, as the macro will only be able to scale down the numbers in range!*/ st,/*start value that can be negative and position*/ end,/*end value*/ by,/*by value for each step; make sure it is matchable with st and end values*/ outmacrov...
7e1bf3b90a40fc2fe9c6ecb40aca762bbeb3f4952ee67cf42a7d4db8d1d8d87a
SAS
4,066
152
%macro principal(Input, vars, Method, p, scoreout, outdata); /* Reducing a set of variables (vars) using PCA, by keeping fraction p (p<=1) of the variance. The output is stored in outdata and the model is stored in scoreout. */ /* First run PRINCOMP to get All the eigenvalues */ %if "&vars"="" %then %do; %let v...
4284dc7dbd902b24cc62eb5a360c92b1397645e89364e6e18f7692c51a794d55
SAS
4,077
141
%macro boxplotbygrp( dsdin=, grpvar=, category_var=%nrstr(&grpvar), valvar=, panelvars=, attrmap_dsd=, fig_height=600, fig_width=600, transparency=0.3, boxwidth=0.5, column_num=4 ); /*proc import datafile="/home/cheng.zhong.shan/data/out.txt" dbms=tab out=x replace;getnames=yes;run;*/ /* proc print data...
7777680a7a4a0898aa5b7fc8080e2350c115172cb8b979cb373b0de97c26d3d1
SAS
4,086
158
%macro ImportFilebyScan( file /*raw data file path*/ ,dsdout /*SAS output dataset name; N.B.: All variables are in character!*/ ,firstobs=0 /*The line number for header; if there is no header, firstobs=0*/ ,dlm='09'x /*Delemiter for raw data*/ ,ImportAllinChar=1 /*Imporat all data as char, otherwise i...
c504243c22d1fc4fb0e61e60b9a02adbf96ec42fc10a0eaa79a17de59573f490
SAS
4,097
95
%macro random_import_cell_mtex4smalldsd( /*Funcational annotation: this macro is suitable for columns no more than 1 million, otherwise, it will be very slow, too*/ gzfile=,/*the fullpath to compressed or plain file, such as gz, txt, zip, and others.*/ max_colnum=1000000,/*If the max number of cells to read from eac...
89ceebfb8df94ab9ffeb2236c5b126d94848abc1fb6b2e3f56ee92f93c1d6164
SAS
4,112
150
%macro VarscanIDs2Bed(VarscanID_dsd, Tbl_or_File, VarName, dsdout, outbed_fullpath ); options compress=yes; /*Be caution that the start of position in BedInfo is equal to the start position -1 of ...
618963ce840ba92668bfa579d7e0c6901f36408ecab373c183bfb63d6f8ef96c
SAS
4,131
66
/*--------------------------------------------------------------------------------------*/ /* Multiple-Plot Displays: Simplified with Macros */ /* by Perry Watts */ /* Copyright(c) 2002 by SAS...
6fc0be3a16e7ea9a3351011f97381f909bb5d6da6e6d1d294f2834b57f82047c
SAS
4,172
158
%macro ImportFilebyScanAtCol( file /*raw data file path*/ ,dsdout /*SAS output dataset name; N.B.: All variables are in character!*/ ,firstobs=0 /*The line number for header; if there is no header, firstobs=0*/ ,dlm='09'x /*Delemiter for raw data*/ ,ImportAllinChar=1 /*Imporat all data as char, otherw...
f9b3c0d89b22afc9ee6bb0e7bf980bc84c8785e5aea1a33e4ce81d2c61194e28
SAS
4,177
119
/********************************************************************** Parameters: root_path - All directories and files under this root will be deleted. The root_path will not be deleted (just empty) lev - Used by the recursion algorithm, no need to modify default rmFiles_lev0 - Set t...
a3cea8381c6c7902f438b825c900f0ae6d1eb600ea64ff56bb4bcccbce8eee3f
SAS
4,179
155
%macro plink_chr_beds_merge( PLINK_EXE, BED_dsd, plink_chr_beds_path, WorkDir, SNP_File, KeepIDsFile, extra_plink_cmd, OutBed ); /*Go working directory*/ /*filter plink BED with several QC parameters*/ %if %sysfunc(prxmatch(/^\//,&WorkDir)) %then %do; *For Linux system; x cd &WorkDir; %end; %else %do; *For windows sys...
a3522054ae6051adc3c1d8de444d36104d41e201086e2c73019621e0c4df0f4b
SAS
4,197
155
%macro ApplyFunc_rowwide( /*The macro is a handy tool to calculate common summary statistics, such as mean, median, sum, n, std, and others that allowed in proc sql when conducting analysis on groups on ROW-WIDE. Additionally, the macro can generate summary statistics by including data from both rows and columns, w...
83acd25f720b420ef1cbbd8f4076eefc47bb05344bec03f00e896f84e19795f9
SAS
4,253
134
%macro _import_sc_mtex_meta_umap_data( /*This macro is replaced by import_sc_mtex_meta_umap_data*/ umap_file=https://cells.ucsc.edu/covid-hypertension/Seurat_umap.coords.tsv.gz, /*local uncompressed or compressed (.gz) umap file or http link for compressed umap gz file*/ meta_file=https://cells.ucsc.edu/covid-hyper...
285f0c28791c81b1cb6c1ad0b40a6240228324fa685f59a54bd7cc74573ca4fa
SAS
4,285
150
%macro GetGenesExons4LatticeGscatter( gtf_dsd=FM.GTF_HG19, /*Need to use sas macro import gtf to save GTF_HG19; the data format for the gtf_dsd is fixed with the following vars: chr st end genesymbol type protein_coding */ chr=, min_st=, max_end=, dist2genes=100000, outdsd=exons ); *Need to first select t...
0381516af6bc9a54bf6646ab5a35fb97c4784ed1ecfb9ae04181f186b3c63b5b
SAS
4,302
111
%macro HGI2GWASs_Zscore_Calculator( gwas1_txt_file=COVID19_HGI_B1_ALL_20201020.txt, gwas2_txt_file=COVID19_HGI_B2_ALL_leave_23andme_20201020.txt, dsdout=B1_vs_B2, HGI_release_num=7 /*before release 7, such as 4, 5, and 6, the input data format are same but different from 7*/ ); *For release 7; /*CHR POS REF ...
1badcdb395ed9bb7cc42bed17958acc69c0aa9660f57b4373b71934a181db54a
SAS
4,331
144
%macro treeorder( data=, /*A typical output generated by proc cluster*/ child=child, /*Equivalent to y_name_ or x_name_ from proc cluster; ensure there is not spaces included in the elements of this variable!*/ parent=parent, /*Equivalent to y_parent_ or x_parent_ from proc cluster*/ hh=hh, /*Equivalent to y_he...
fab3efc9db71458ce2827b91493824e17cf72c1ee6c5debf5306f26b44109183
SAS
4,331
165
%macro ImportPartialFilebyScan( file /*raw data file path*/ ,dsdout /*SAS output dataset name; N.B.: All variables are in character!*/ ,firstobs=0 /*The line number for header; if there is no header, firstobs=0*/ ,rows=1 /*How many rows will be imported after the header line*/ ,dlm='09'x /*Delemiter f...
aabb0546f9c0f5f0f173a407f833206b0e6d608a8d0268eeec6a9668fd4d1360
SAS
4,333
173
%macro UniqNumGeno4VCFsamples( /*Focus on SNPs that have different genotype in the current sample by comparing the genotype with other samples; Also request the genotype to be het or homo for the alternative allele; Additionally require the numeric genotype > other samples genotypes; tmp=tmp+(G{ii}^=G{xi})*(G{ii}>0...
1a406cd3aa749a5dc8204f272fb3a106d2b53b18c62ecbff3fb6891c1877a7e8
SAS
4,341
178
%macro GEO_Pipeline(/*As different GSE and GPL files use specific genesymbol and probe ids, it is better to run the macro without knowing these headers for them, If failed, it can be rescued by evaluating these genesymbol and probe ids in the SAS output dataset*/ GSE_matrix_file=, dlm4matrix='09'x, ProbVarInMa...
6203f4de6b0fe0a55995883824d6aa82fcf860577c109380ac70a22828067032
SAS
4,369
139
%macro tree_CL_positions_bad( /*The macro will get avg positions of all end leaves of each brach, which is not what is used by SAS to draw dendrogram. In fact, the two 1st degree sub-branches of each non-end-leaf branches are used to draw the middle position for each non-end-leaf branches! Please use a better macro, c...
e7080f60024b9c49824447fd577d444157f4e3396a1f992a02f278882b93c6a2
SAS
4,369
164
%macro Barchart_color_template(colors,temp_out); /*SAS codes for defining colors for ods output*/ /*https://support.sas.com/kb/48/138.html*/ /*https://support.sas.com/rnd/base/ods/templateFAQ/Template_colors.html*/ /*WHITE #FFFFFF*/ /*BLUE #0000FF*/ /*YELLOW #FFF00*/ /*BLUE VIOLET #9F5F9F*/ /*BROWN #A62A2A*/ ...
65dac1d3f6cb4ac39f8c6067b073624d1794446f34abd349b961a68d1a396fe4
SAS
4,391
153
%macro GDC_MutIDs2Bed(GDC_MutID_dsd, Tbl_or_File, VarName, dsdout, outbed_fullpath ); options compress=yes; /*Be caution that the start of position in BedInfo is equal to the start position -1 of ...
3a2691a93e71ddefa38c6afabc93f2f69cdb7debada13dbbdc328a1048795696
SAS
4,446
92
%macro SASZip_Lite(zip=, sfdr=, fstyl=, tfdr=); /**************************************************************** The code posted below is provided "AS IS" with NO WARRANTIES. ZIP: directory and file name of zip archive SFDR: directory of source files (to be zipped) FSTYL: File type of source files; value: *.* as ...
c356e716ea811e1dedc6257753a4548fc8d922881d093d2289c23e0631102a70
SAS
4,473
185
%macro sexdiffgwaspipeline( male_gwas=, female_gwas=, snp_varname=SNP, chr_varname=chr, pos_varname=BP, beta_varname=beta, se_varname=se, p_varname=P, Allele1_varname=A1, Allele2_varname=A2, MAF_varname=AF_Allele2, MAFcutoff=0.05, gwasout=out); /*proc import datafile="female.20016_irnt_Fluid_intellige...
f8f452d0b117d9675341dc315df83c3933feca9403b9fcc13e4feb38fbdd99da
SAS
4,513
126
%macro Run_7Zip(Dir=, /* Windows path of directory to examine*/ filename=, /* Target for 7Z */ Zip_Cmd= x, /* add commands listed belowing, such as x to run with fullpath and e to extract with filename wit...
3abb0998e4516b986c5a16e8653fbdf81856ef1f1bbde4c8638f61a99273829c
SAS
4,573
165
*Note: the colors used to filled bed regions and its complementary regions can be customized; *by revising the macro manually; %macro bed_block_complement4blockplot( dsdin, chr_var, chr_value, st_var, end_var, dsdout, minst, maxend, generate_dsd_only, use_alternate_mode2fill_blocks=1 /*When the value is 1...
9dd4090d67d69b5d81da2ccd43f15d21c9749b31c278aadea3080ae206d6da3e
SAS
4,578
154
*****************************************************************************; ********************** Wilcoxon Rank Sum test Macro: **********************; *****************************************************************************; /* notes/documentation %wilcoxon(indata=test6, outdata=out_wilcox1, var=ser_plan s...
a6600039e6e17036a34f3bab7988a98f573b7532bf6a5c72e028e39e614b79a3
SAS
4,594
179
%macro get_UKB_gwas_from_UKB(gwas_url,outdsd); %let wkdir=%sysfunc(getoption(work)); %let gwas_gz_file=%sysfunc(prxchange(s/.*\///,-1,&gwas_url)); %dwn_http_file(httpfile_url=&gwas_url,outfile=&gwas_gz_file,outdir=&wkdir); /*Put tmp data into sas work directory will save space*/ /* %ImportTXTFromZIP(zip=&wkdir/&gwas_gz...
21eae7f272a87fe970f407c1d56bc2e8a972d8c4c0dc6e386083ddc2fb195f6a
SAS
4,649
135
%macro Varscan2Annovar(VarscanTable_fullpath,dsdout,annovar_input,annovar_dir,annovar_outdir,Anno_dsd_out); options compress=yes; *Be caution that the start of position in ANNOVAR is equal to the start position -1 of UCSC!; data ANNOVAR; length A1 A2 $32767.;*This is for avoiding truncation of large deletion; ...
27b2e0056de2d105015f1d5432fe7b2352c98c842f36a2b8e8a13c933032dd61
SAS
4,681
140
%macro import_sc_mtex_meta_umap_data( umap_file=https://cells.ucsc.edu/covid-hypertension/Seurat_umap.coords.tsv.gz, /*local uncompressed or compressed (.gz) umap file or http link for compressed umap gz file*/ meta_file=https://cells.ucsc.edu/covid-hypertension/meta.tsv, /*meta data for the single cells and sample...
654774905cb12dd2e7a4e13d727b15473a1b9dc1a6d491e69d401724b78c73d9
SAS
4,901
176
%macro rm_cols_gt_nmissing( dsd,/*Input data set; it can be subsetted if not all numeric or character vars are targetted before supplying to the macro*/ var_type, /*_numeric_ or _character_; if only specific numeric or character vars are targeted, please subset the input dsd based on specific variable names*/ ...
cf48aa796434d13ceb8a1888febe02b25c743b899ce35e471440a2b5e7e91c98
SAS
4,904
120
%macro import_ncbi_gpff( gpff_url=https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/405/GCF_000001405.40_GRCh38.p14/GCF_000001405.40_GRCh38.p14_protein.gpff.gz, outdsd=hg38_gpff ); %let OldOutDsd=&Outdsd; *If the outdsd contains lib abbreviation; *It is necessary to generate a gbff dsd in working directory f...
4347dbd4de8ed69b6a70b2382390ec84e23e272cb5110220686faf8354442bec
SAS
4,973
196
%macro sc_glm4genes( /*Note: sc_freq_boxplot also perform DEG analysis, which is better than this macro However, this macro can be used for GTEx DEG analysis between sex or ancestry, such as between AA and EA, if these grp information is added into the umap dataset manually! */ dsd, dsd_headers, dsd_umap, gene...
c51f190f3ff8c65b3c13032905958c275ec3c418e4527bd4848e005a1e1342d2
SAS
4,989
219
%macro add_fake_pos_by_grp4nonnegvars( dsdin, axis_var,/*No negative values are allowed for the target axis var*/ axis_grp, new_fake_axis_var, dsdout, /*Two new variables, tag var and tpos, can be used to draw a ref line to separe each group*/ axis_step=1, /*Add extra step to separate each group for the end value...
75d9bbd91c6dd2a5b1e64447ab91323cf3403ae8a9b851f69f52fe236f0fb7bd
SAS
5,058
163
*https://blogs.sas.com/content/iml/2019/11/13/create-biplots-sas.html; %macro Biplot( data=_LAST_, /* Data set for Biplot */ var =_NUMERIC_, /* Variables for Biplot */ id =ID, /* Observation ID variable */ dim...
d2403115fcf6e2cfce5c95d241f1223a26d4984937b91ee64ccd3bf1120a07f8
SAS
5,065
199
%macro glm_by_grps( dsd=tgt,/*Long format data for proc glm*/ grpvars=rownames cluster, yvar4glm=exp,/*var in the dsd for proc glm*/ GLMStatOutDsd=GLMStatOut, GLM_classes=sex medication severity, GLM_model=severity sex age medication, pheno_var=severity, /*var for lsmeans analysis in proc glm*/ where_condition=, exp_cu...
134fd32f02d16bdff9ef028997ca6dfe89af4b2b704682081cd5ca2b65a30975
SAS
5,078
143
%include "%sysfunc(pathname(HOME))/Macros/importallmacros_ue.sas"; %importallmacros_ue; %let gwas=/home/cheng.zhong.shan/data/LongCOVID/CombineLongCOVIDGWAS.txt.gz; %ImportFileHeadersFromZIP( zip=&gwas,/*Only provide file with .gz, .zip, or common text file without comporession*/ filename_rgx=., obs=max, sasdsdout=gw...
9bdee004d908f6aa7c46c852f11efe79fb7618a81e17c84faf91e626bc082594
SAS
5,121
197
%macro get_macros_used_by_macro_old( macrorgx=., dir=%sysfunc(pathname(HOME))/Macros ~/shared/Macros /home/zcheng/SAS-Useful-Codes/Macros F:/360yunpan/SASCodesLibrary/SAS-Useful-Codes/Macros /home/zhongshan/SAS-Useful-Codes/Macros , outdsd=macros, verbose=0, IsSASOnDemand=0 ); %if &sysscp=WIN %then %do; %put Find y...
5edb45947e6889fd5889d458cacfe94b17930d3a36461e2aada9c88caa784b1c
SAS
5,155
199
%macro ImportFilebyScanAtSpecCols( file /*raw data file path*/ ,dsdout /*SAS output dataset name; N.B.: All variables are in character!*/ ,firstobs=0 /*The line number for header; if there is no header, firstobs=0*/ ,dlm='09'x /*Delemiter for raw data*/ ,ImportAllinChar=1 /*Imporat all data as char, o...
e413decf02f7812fbabe7b421302757d564a2c3f8d916736028d566c963635bd
SAS
5,185
243
%macro Adj_missing_cell_value4fisher( /*This macro will add value of 1 to the 2x2 contigency table derived from the input long format dsd*/ longformdsd=,/*long format dsd containing >=3 columns: group var and pheno var, as well as a by variables*/ grp_var=grp,/*grp var for proc freq grp*pheno*/ pheno_var=new_pheno,/*ph...
54d8bad1c28e3d4af49e16c050c552cc2de9af9a7e2dbaacd0a200a58f9710d2
SAS
5,262
186
%macro ImportCovidGWASFromZIP(zip,filename_rgx,sasdsdout,deleteZIP); %local nfiles txtfilenames txtfilename; options compress=no; %local gzip_tag; /*do not quote the keyword gz for index function*/ %if %index(&zip,gz) %then %do; %let gzip_tag=gzip; %end; %else %do; %let gzip_tag=; %end; %if &filename_rgx eq %then...
deaa64123ed68f86a993f688617091656443222c0cefef9242b6a2b43631a2d4
SAS
5,281
190
%macro ImportGendcodeGTFFromZIP( zip, filename_rgx, sasdsdout, deleteZIP, Use_zcat=0 /*if the gzip option is not availabe for old sas, use zcat in linux to replace it!*/ ); %local nfiles txtfilenames txtfilename; options compress=yes; %local gzip_tag; /*do not quote the keyword gz for index function*/ %if %i...
969434523d91db396e397c8dd1b1f5f0853f1489a563b2067893bc4b12e2ec3a
SAS
5,294
154
%macro RunKggseq( java_bin= /* Only single comma; when just run java with 'java -jar', it does not work, as sas use its inernal java */ , Kggseq_dir= /* Windows path of directory to Kggseq jar */ , dir= /...
31c0a3cbad97012ed2bf8055e30a6489e6da6f014d79575e341c2f92d04338d7
SAS
5,348
188
*Note: this macro is only able to import HGI GWAS from GRASP but not HGI database; %macro ImportHGICovidGWASFromZIP(zip,filename_rgx,sasdsdout,deleteZIP); %local nfiles txtfilenames txtfilename; %let infile_command=%str( informat chr $5.; informat pos best32.; informat REF $1.; informat ALT $2.; informat SNPI...
b465c6cc34229f971447caf8e190762135b918b5cb60d5da645bb9cc7ec3e10e
SAS
5,352
204
%macro get_sc_read_geomean_and_readsum( filename_ref_handle, /*filename handle, and all character columns should be put at the beginning of the table!*/ total_num_vars, /*total number of numeric vars in the opened file handle*/ macro_prefix4NumVarSum, /*macro prefix used to generate macro vars for var sums*/ firstobs...
be837ab17941e6cfc935b685bc348207030fd9e45a5de19060333eb3a5faf3c0
SAS
5,366
165
*This macros will use many other internally included macros in current file; *the following sub-macro is renamed to avoid of crash with other macros within; *the SAS macro library; %macro DirRecursiveSearch_(root_path=_NONE_,lev=0,SR_Files_lev0=Y); /****************************************************************...
0c598a7570d85953ab2f3d3760b7e6c593903ff0e227e05211ab84b9fbda1a3d
SAS
5,492
211
%macro OneKG_Assemble( PLINK_EXE, BED_dsd, OneKG_Path, WorkDir, SNP_File, KeepIDsFile, extra_plink_cmd, OutBed ); /*Go working directory*/ /*filter plink BED with several QC parameters*/ %if %sysfunc(prxmatch(/^\//,&WorkDir)) %then %do; *For Linux system; x cd &WorkDir; %end; %else %do; *For windows system; x cd "&Wor...
2ecce3a9e2daceb694aaf6347f7f9e869538f15d686ea95ff2764955c7e207b0
SAS
5,534
211
%macro GRASP_COVID_Hosp_GWAS_Comparison( gwas1=https://grasp.nhlbi.nih.gov/downloads/COVID19GWAS/10202020/COVID19_HGI_B1_ALL_20201020.b37.txt.gz, gwas2=https://grasp.nhlbi.nih.gov/downloads/COVID19GWAS/10202020/COVID19_HGI_B2_ALL_leave_23andme_20201020.b37.txt.gz, outdir=%sysfunc(pathname(HOME)), /*SAS GWAS data sets, ...
dd5ec02cac1430a22dd4a9213d266b2481f7e88527a019a9ef97fd4beb1e6ddf
SAS
5,581
204
%macro sas_pgm_printer( pgmrgx=., dir=%sysfunc(pathname(HOME))/Macros \stjude.sjcrh.local\data\ResearchHome\ClusterHome\zcheng\SAS-Useful-Codes\Macros H:\F_Queens\360yunpan\SASCodesLibrary\SAS-Useful-Codes\Macros ~/shared/Macros /home/zcheng/SAS-Useful-Codes/Macros F:/360yunpan/SASCodesLibrary/SAS-Useful-Codes/M...
5e086a937a719d49286c7c762e023bb5c9f6af34ac997a4a0a893e4c1657fc42
SAS
5,591
169
%macro get_sigs_from_locuszoom( gwas_names=91854 192226 826733 793752, /*put multiple gwas numbers and separated with blank space; Go to locuszoom to search for gwas and nevigate to specific gwas and obtain its gwas number in the weblink*/ gwas_labels=HGI_DF4_W1 HGI_DF4_N2 HGI_DF4_W2 HGI_DF4_N1, /*These are labels...
f41556756bb88f5d93671429260f901faae8cabbd31eb2899f3c14fb697a1001
SAS
5,652
185
/* This macro program first generates the orders and quotes data sets, then joins them using both the SAS PROC SQL and the SyncJoin algorithm, and finally compares the results from the two approaches. By systematically changing the parameter values and invoking the macro repeatedly, the performance differences betw...
ee9be6434efe53be3aa34d660966ea910ec0832ee7a9905be8f6092d7984db4e
SAS
5,665
210
%macro get_macros_used_by_macro_orig(/*This macro may run endlessly when the macro include its macro name without the Demo tag*/ macrorgx=., dir=%sysfunc(pathname(HOME))/Macros ~/shared/Macros /home/zcheng/SAS-Useful-Codes/Macros F:/360yunpan/SASCodesLibrary/SAS-Useful-Codes/Macros /home/zhongshan/SAS-Useful-Co...
f5a0edae59a7d4b36f267cd262faf216996d9b1d620c0deca4cc7ca300c6b594
SAS
5,708
215
%macro macroparas( macrorgx=., dir=%sysfunc(pathname(HOME))/Macros \\stjude.sjcrh.local\data\ResearchHome\ClusterHome\zcheng\SAS-Useful-Codes\Macros H:\F_Queens\360yunpan\SASCodesLibrary\SAS-Useful-Codes\Macros ~/shared/Macros /home/zcheng/SAS-Useful-Codes/Macros F:/360yunpan/SASCodesLibrary/SAS-Useful-Codes/M...
eaaf505975f08f70afb80f984d9944c06dbf4b7c08cc1bfb1e1e790d779170e4
SAS
5,719
221
%macro bed_region_plot_by_grp( bed_dsd, chr_var, st_var, end_var, grp_var, yval_var, linethickness=20, track_width=800, track_height=400, dist2st_and_end=0 ); %number_rows_by_grp(dsdin=&bed_dsd,grp_var=&grp_var,num_var4sort=&st_var,descending_or_not=0,dsdout=x1); data x1(keep=&chr_var pos &yval_var &grp_va...
30c8ce2468415450d79b4971e4f3a0e174a8d7a58654a22bcf2946c336f8f421
SAS
5,820
172
%let macrodir=%sysfunc(pathname(HOME))/Macros; %include "&macrodir/importallmacros_ue.sas"; %importallmacros_ue; *************Step1***********************; %GRASP_COVID_Hosp_GWAS_Comparison( gwas1=https://grasp.nhlbi.nih.gov/downloads/COVID19GWAS/10202020/COVID19_HGI_B1_ALL_20201020.b37.txt.gz, gwas2=https://grasp.nhl...
8290d4ba77883424a33ec6adccba0e1cbff5377f2702603fffabd040fcac754b
SAS
5,828
181
%macro Multgscatter_with_gene_exons4dsd( bed_dsd=, yval_var=, scatter_grp_var=, gene_exon_bed_dsd=, dist2st_and_end=50000, design_width=1000, design_height=200, barthickness=20, makedotheatmap=0,/*use colormap to draw dots in scatterplot instead of the discretemap; Note: if makedotheatmap=1, the scatterplot will not us...
50153a97faa9058b24071771dd6c7acd95c86da566fbbb579e750ae01dc78ebb
SAS
5,840
173
%macro DROPMISS( DSNIN /* name of input SAS dataset */ , DSNOUT /* name of output SAS dataset */ , NODROP= /* [optional] variables to be omitted from dropping even if they have only missing values */ ); *Read the original paper for detail; *https://www.lexjansen.com/nesug/nes...
dc1faed37ab65b28bc150cf58f2e6e2628893ddea4e07bb115c6566feba75105
SAS
6,040
195
%macro LocalScatterplots4MultGWASs( longformatgwasfile, Chr_var, Pos_var, GWAS_var, beta_var, rsid_var, P_var, subChr, subStPos, subEndPos, otherfilters4whereCondition, rsid_reflinepos, rsid_ref, log10pRef, pcutoff, FigHeight, FigWidth ); %if %sysfunc(exist(work.x)) %then %do; %put using previou...
4ec305c3782c24e62cb61134d4e86896cdee281f1b521292a6fffbb4908d3519
SAS
6,079
234
%macro ImportAllFilesInDirbyScan( fileDir /*raw data file dir*/ ,fileRegexp /*regexp to match files*/ ,dsdout /*SAS output dataset name; N.B.: All variables are in character!*/ ,firstobs=0 /*The line number for header; if there is no header, firstobs=0*/ ,dlm='09'x /*Delemiter for raw data...
efcac71da8c7b075bd2ff640cd3c0e7a7f428a87cf8a09bde1ee02f20c7eda4e
SAS
6,222
155
%macro tolong(widedata,longdata,id,suffix,suffixlo,suffixhi,vars,types=,lengths=,numprint=,quiet=); /* widedata - name of input data file that is in wide form longdata - name of output data file that will be in long form id - variable that uniquely identifies the wide records suffix - variable n...
fb11a64f2baff33b33158c8a7b7c5ac196eca605f3762f8cbe5e0f9917d6daae
SAS
6,269
227
%macro get_numeric_table_vars_length( filename_ref_handle, /*filename handle, and all character columns should be put at the beginning of the table!*/ total_num_vars, /*total number of numeric vars in the opened file handle*/ macro_prefix4NumVarLen, /*macro prefix used to generate macro vars for var lengths*/ firstob...