sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
55a753695d7790777fca7154678dfe594ca76444b8a11f2f915c6f0052d2c321
SAS
1,687
52
*Note: file_rgx is char insensitive for prxmatch; %macro list_files2globalvar(dir,file_rgx,filelistvar); %global &filelistvar; %let &filelistvar=; /*reset the value of the global macro var*/ %local filrf rc did memcnt name i; %let rc=%sysfunc(filename(filrf,&dir)); %let did=%sysfunc(dopen(&filrf)); ...
59713c371a957505206e9366a4c0905feeff89fada52d84669762756699c3ca4
SAS
1,695
63
%macro trans2tranv_fmt(dsd,mut_var,new_mut_var,mult_types); %put Only focus on single site but not indel site; %put ref_alt should be separated by |,i.e., A|B and mut_var should be chrnum:pos-A|B; /*Only single mutation*/ %if &mult_types=1 %then %do; proc format; value $ trs 'A->C','C->A'='A>C' 'A->G...
a059cbff8051c335271e87309856df343e676ad785f62d43c2598645ec8026c9
SAS
1,720
76
%macro QueryGTExeQTLs4Genesymbol( geneids=Apobec3a Apobec3b,/*For Apobec3a*/ outdsd=gene_eqtls ); %let gstot=%ntokens(&geneids); %do _gsi_=1 %to &gstot; %let geneid=%scan(&geneids,&_gsi_,%str( )); %let api=https://gtexportal.org/api/v2/reference/geneSearch; %let url_link=%str(&api?geneId=&geneid); file...
337af294c53c1e4ba61616221a30e494fedbcbad60d93a6fe3a254aac98a6b33
SAS
1,723
59
%macro get_vars_max_length( dsdin=, vars=, macrotag4varslen=_max_var, /*global macro variables containing the length for each variable will be created by adding numeric orders in according to the order of input variables*/ rm_leading_spaces=1,/*Not count the leading spaces in each var*/ dsdout=_tmp_ /*Output a d...
8d3cc098fa72c342b42d96ae6157e28d6053bb0d46a7ce4f9d667794f2219867
SAS
1,735
65
%macro Make_Where_In_Item_List( query_name, /*query variable name that will be put before the "in" command in the final codes of where condition; Note: this variable name should be contained in the data set that will be applied for where condition! It does not require to be included in the input data set indsd that ...
d6df05e9d3d1efaf771af2df1a441036b26c518e1be82d63054406c6c1ba00a4
SAS
1,743
56
%macro get_consecutive_num4linker(nums_with_linker,global_macro_out,linker=-); %global &global_macro_out; *replace numbers with linker to consective numbers; %if %sysfunc(prxmatch(/\s*&linker\s*/,&nums_with_linker)) %then %do; %let _nums_with_linker_=&nums_with_linker; %let n_linkers=%sysfunc(countc(&nums_with_linker...
f34165c4da445a01c66891b4277f9d82ce5a0896347bfa3f9b051148b62dca93
SAS
1,743
64
%macro matrix4cluster(dsdin, distance_method, dist_matrix_out, dendrogram_out, cluster_method, id_var4cluster, numeric_vars ); *Remove records with id_var4cluster as missing; data &dsdin; set &dsdin; if &id_var4...
cf3c48cb9ee32786b21aacce66c13e6e9944b2ee16df81f52e395311de6163dd
SAS
1,749
71
%macro ucsc_cell_matrix2longdsdBAD( gzfile_or_url, dsdout ); %if %eval(%sysfunc(prxmatch(/http.*gz/i,&gzfile_or_url))=1) %then %do; *Download exp matrix gz file; *In SAS ondemand, putting data into the temporary work directory will not be limited by the 5GB quota!; %dwn_http_file(httpfile_url=&gzfile_or_url,outfile...
3b4c1b081d6ee976008e8b4eb06c7519bd83db28c1ad8de986bc3d2db1ce545a
SAS
1,753
70
*options mprint mlogic symbolgen compress=yes; %macro AdjDupsInBim(BimFullpath,BimSep); data _NULL_; filepath="&BimFullPath"; retain length_SNP_ 0 length_A1_ 1 length_A2_ 1; infile dummy filevar=filepath length=reclen end=done; do while (not done); input; length_SNP=length(scan(_infile_,2,&BimSep)); length_SNP_=IFC(len...
bc3b52eaa15523803d066fa7ad158adb1d968a63a60171724d535686b4a42fa6
SAS
1,755
50
%macro combination(r)/parmbuff; %let i=2; %let things=; %do %while (%Qscan(&syspbuff,&i,%STR(,%))) ne ); %let p&i="%Qscan(&syspbuff,&i,%STR(,%)))"; %if &i=2 %then %let things=&&p&i; %else %let things=&things,&&p&i; %let i=%eval(&i+1); %end; %let n...
ff1c1070c9f432faedc28214660163887d2728602a0766f883a6000bb5bb8c4d
SAS
1,756
67
/** @file @brief Creates a directory, including any intermediate directories @details Works on windows and unix environments via dcreate function. Usage: %mf_mkdir(/some/path/name) @param [in] dir Relative or absolute pathname. Unquoted. @version 9.2 **/ %macro mf_mkdir(dir )/*/STORE SOURCE*/; ...
172d71c789e0ad578b94c5d4edce928dd2de55b347aa123236ec560e25910300
SAS
1,779
83
*options mprint; %macro Delete_DataSets_In_Lib(lib,excel,excluded,dsd_not_contain_rgx,dsd_contain_rgx); %let re=%sysfunc(prxparse(s/ /" "/oi)); %let rm_list=%sysfunc(prxchange(&re,-1,&excluded)); %syscall prxfree(re); proc sql noprint; create table temp_xyz as select * from dictionary.tables where (libname...
45596970b3f767ca80ab9d3cd5f857c303da9b925ce396b6d81dad8da2995aae
SAS
1,782
58
%macro rm_rows_gt_nmissing( dsd=_last_, nmissing_cutoff=1, /*Remove rows with more than or equal to 1 missing records*/ reverse=0,/*Default is 0 for removal of rows with total number missing vars >= nmissing_cutoff; Assign value 1 to revease the search to obtain rows with at least the specific number of non-missin...
6f8d3fc11cf42f567af8c09e481fc89ef204e7e5fee0d7b7ac23ff1711c940c1
SAS
1,784
80
%macro query_LD_SNPs_among_1KG_pops( /*https://rest.ensembl.org/documentation/info/ld_id_get Computes and returns LD values between the given variant and all other variants in a window centered around the given variant. The window size is set to 500 kb.*/ snp=rs17425819, outdsd=out, pop=GBR /*Provide one population o...
1dc696f0915124577fdd990d80dd9e989391dbaa51c0384b43c2498020ded6fa
SAS
1,790
56
%macro AnyOf(vars=, calculated=, cond=eq 1); %local mc mv n v; %local allvars var; %if %length(%superq(vars)) eq 0 %then %let mv = 0; %else %let mv = %ntokens(&vars); %if %length(%superq(calculated)) eq 0 %then %let mc = 0; %else %let mc = %ntokens(&calculated); %let allvars = &...
b28f41aab2e06e803debf8afd539fab544740f61ee331dc702c517ad5d49691d
SAS
1,799
71
%macro calculate_binomial_P( dsdin=_last_, /*SAS input data set for calculating binomial P*/ dsdout=, /*output sas data set that contains the newly created binomial_P and its -logP*/ Allele1_var=V1,/*Counts for variable allele 1, usually the ref allele, such as allele 1 in ASE*/ Allele2_var=V2,/*Counts for variable...
c90b1b2acb6a947df3a955fb541e629bcb3dea30dbfdcd2bc98e63b80d667aba
SAS
1,816
62
/* MACRO %GetVarAttrib Version: 1.00 Author: Daniel Mastropietro Created: 07-Jun-2012 Modified: 07-Jun-2012 DESCRIPTION: Returns the requested attribute of a given variable in a dataset. USAGE: %GetVarAttrib(data, var, fun); REQUIRED PARAMETERS: - data: Input dataset where the variable of inter...
2f6e5195b13c6a5d808c2466a1d384f1b335ded0091bc5f3787fa4a11a0bb2bf
SAS
1,848
92
%macro map_assoc2gene4covid19( gwas_dsd=FM.f_vs_m_mixedpop, gtf_dsd=FM.GTF_HG19, chr=, min_st=, max_end=, AssocP=pval ); proc sql; create table signal_dsd (where=(var4log10P>=1)) as select pos as st,pos+1 as end,-log10(&AssocP) as var4log10P, "Signal" as grp,cats("chr",put(chr,2.)) as _chr_ from &gwas_dsd where...
f3433790f6d35ba486bae862c62fed601a799134c17e4e8f1fa35fd708d0633f
SAS
1,849
78
/*%macro import_fasta_like_file(fasta_like_file,header_start_char,outdsd);*/ %macro import_fasta_like_data(/*Generate codes for running with parmcards in data step*/ header_start_char,/*It is defined to match more than one characters!*/ outdsd, onelinemode=1 ); /*clear and create new temp file*/ filename FT15F...
5cbc53d625ddc16619b0af1160a2c744a8d174b61066f3bae98e0a5e51b47aba
SAS
1,861
77
%macro QQplot(dsdin,P_var); proc sql noprint; select count(*) into: tot from &dsdin; data &dsdin; set &dsdin; where &P_var>0; *sort and exclude these missing P values; proc sort data=&dsdin; by &P_var; run; data dataout; set &dsdin; retain x_; gap=1/&tot; ini=gap/2; if _n_=1 then x_=ini; else x_=x_+gap; x=-log10(x_)...
0c38aaded52a0521eec4c215a251e8cabec1218c229d1aed5c5a8697012bf6e0
SAS
1,863
64
*https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PACKAGE-with-CALL-EXECUTE-not-quot-releasing-quot-created/td-p/720928; %macro ZipFolder4AllFiles(target_dir,outzip,outdir,rgx2keep_file=.); /* This macro will try to get all files without spaces and compress them into a single zip file; Limitations: (1) files f...
7213c0785c39629b99d86e64b0a20ab6c754e3740c9c19de3a85c89f5c421bff
SAS
1,904
72
%macro import_mult_numbat_scASE( ase_dir=, /*a dir containing numbat scASE results for all samples, with each sample has a single subdir*/ outdsd4all=, /*Output scASE data for all samples*/ gene_DP_cutoff=10,/*Coverage cutoff for all snps in a single gene*/ out4all_cell_gene_summary= /*cell gene summary for all sam...
50ddfc24d31d5d2bbeaa2bb7bf1d601b245e7793e26ac94d963b6cf4f41aed13
SAS
1,913
61
%macro parse_macro_paras(macro_filepath,dsdout); data &dsdout; infile "&macro_filepath" lrecl=10000 obs=max; input; Macro_Info=_infile_; run; /**Print macro with specific style;*/ /*title "Contents of first &numlines2print lines of SAS macro: &macro_filepath";*/ /*proc print data=_macros_ noobs;*/ /*var Macro_...
975212504a33769674e50c58a6b7335e352a32cd7889ed13a3d6788926590273
SAS
1,917
65
%macro char_grp_to_num_grp( dsdin=, grp_vars4sort=, descending_or_not=, dsdout=, num_grp_output_name=, keep_uniq_rows_by_grp=0 ); /*Note: if keep_uniq_rows_by_grp=1, then only unique grps will be remained in the final dataset*/ %let nvars=%numargs(&grp_vars4sort); *Use key instead of by in the proc sort, as u...
b375a9788d1c15f61811d6d70dc71382f66b61bc00dc06e3b3b3bd7cd9f274ba
SAS
1,928
58
%macro import_numbat_scASE(/*Function annotation: Import Numbat generated single cell ASE read matrix and perform descriptive summary for genes passed the depth threshold in each single cell*/ file=,/*fullpath to Numbat generated scASE sample_allele_counts.tsv.gz file*/ outdsd=sc,/*Output for unfiltered scASE read cou...
db1e4abb911e801a53f78c45473d8b7e779127c101d9daa72fa55b5358d2d239
SAS
1,942
46
*options macrogen mprint symbolgen mlogic; *Be caution about the use of _str_, if it used two times in a line,some unknown errors always occure!!!!!!!!; %macro Append_All_Data_in_Lib(lib,excluded,dsdout); %let re=%sysfunc(prxparse(s/ /" "/oi)); %let rm_list=%sysfunc(prxchange(&re,-1,&excluded)); %syscall prxfree(r...
17db320f2370a321ee6e90a1d3fd24c69eac84f964c88c01288a347de243164c
SAS
1,944
49
%macro direxist /*---------------------------------------------------------------------- Test if directory exists ----------------------------------------------------------------------*/ (path /* Name of directory to test for existance */ ); /*-------------------------------------------------------------------...
b2e29ffc23343239501002827b3712ccc00c1f692f8795a5875558bcd0123493
SAS
1,950
118
%macro mkfmt4grpsindsd( targetdsd, grpvarintarget, name4newfmtvar, fmtdsd, grpvarinfmtdsd, byvarinfmtdsd, finaloutdsd ); *apply informat and format to sort panel by a; *see differences between informat and format:; *https://documentation.sas.com/doc/en/pgmsascdc/v_010/proc/p06ciqes4eaqo6n0zyqtz9p21nfb.htm; *informat i...
90a8f3c085b6ce4e85893e88f1defb492584af769e3487b20063ad3de2d3c602
SAS
1,991
70
%macro square_boxes( inputdsd=_last_, x=x, /*x-axis variable*/ y1=y1, /*y position 1 with the same x position as y position 2*/ y2= ,/*y position 2; if y2 is empty, y1+width will be used as y2*/ width=0.5, /*width for the square from (x,y1) to (x,y2)*/ outdsd=out,/*output dsd for making square with proc sgplot p...
81f3a7ce5320126f50b4c16c28205399337d7702ebf7ea8950aaf68fc996ef79
SAS
1,992
98
%macro map_grp_assoc2gene4covid19( gwas_dsd=FM.f_vs_m_mixedpop, gtf_dsd=FM.GTF_HG19, chr=, min_st=, max_end=, AssocP=pval, AssocGrp=, ); proc sql; create table signal_dsd (where=(var4log10P>=1)) as select &AssocGrp > 0 as &AssocGrp, pos as st,pos+1 as end,-log10(&AssocP) as var4log10P, "Signal" as grp,ca...
3b3d53c38f0ae98e68fd03c3a96ccfc599faf5b754dab9df70ac90f65f3fd9bc
SAS
1,993
69
%macro subset_bed(bed_dsd,bed_chr_var,bed_st_var,bed_end_var,query_chr,query_st,query_end,subbed_out,numeric_chr_in_bed_dsd); %let chr_tag=%substr(&query_chr,1,3); %put your query chr is in the format of &chr_tag; %if (&numeric_chr_in_bed_dsd=1) %then %do; %if "&chr_tag"="chr" %then %do; %put Request...
601abffcc89fbefa2924371512e326992c17923ed919360f7214b53cb69b94f1
SAS
1,998
87
%macro get_grasp_covid19_gwas_links(dsdout=grasp_covid_gwas_info); filename graspout temp; proc http url="https://grasp.nhlbi.nih.gov/covid19GWASResults.aspx" method="get" out=graspout; run; data grasp_info; infile graspout lrecl=32767 truncover; input; info=_infile_; run; filename graspout clear; data g...
a078645791cfa5f92842490a4e26a271319800818eccc0fb37ac193c66f6bf8a
SAS
2,028
86
%macro QueryInterVar( chr=1, pos=115828756, ref=G, alt=A, build=hg19, dsdout=results ); %let query_url=%nrstr(http://wintervar.wglab.org/api_new.php?queryType=position&chr=)&chr.%nrstr(&pos=)&pos%nrstr(&ref=)&ref%nrstr(&alt=)&alt%nrstr(&build=)&build; filename J temp; /* proc http url='http://wintervar.wglab.org/api_ne...
2d41bd3ef3bef8d0d17946c7fe8cdd32ef8a22c9a8c83276f8cb62115747218e
SAS
2,029
78
%macro QueryGTExeQTLs4MultEnsemblGenes( ensembl_gene_ids=ENSG00000128383.12,/*For Apobec3a Apobec3b and others, separated by blank space;*/ outdsd=gene_eqtls ); %let ngenes=%ntokens(&ensembl_gene_ids); %do _gi_=1 %to &ngenes; %let ensembl_gene_id=%scan(&ensembl_gene_ids,&_gi_,%str( )); %let url_link=%bquote(https...
f23558e9c8503f6517d83ae3fac7a7ee875da1a62a014a6fe8dbe7f62ce3b238
SAS
2,034
67
%macro RecSearchFiles2dsd(root_path,filter,perlfuncpath,outdsd,outputfullfilepath); *options nosource nonotes; %if "&root_path"="." %then %do; %put relative path is not allowed, please provide fullpath for the var root_path!; %abort 255; %end; %else %if %FileOrDirExist(&root_path) ne 1 %then %do; %put Se...
8198914e511068a1bffc04297958750ed2db5aef7990abf4a141de097e6189be
SAS
2,042
66
%macro geo_sample_info_in_gse_matrix_gz( gse_matrix_gz_url=https://ftp.ncbi.nlm.nih.gov/geo/series/GSE267nnn/GSE267625/matrix/GSE267625_series_matrix.txt.gz, outdsd=sample_info, debug=0 ); %CheckHeader4GZ_URL( any_gz_url=&gse_matrix_gz_url, infile_cmd=%str( firstobs=1 obs=max; input;info=_infile_; if info...
45563546542078dca983e6fbb7e562e4dc0abf0b0ce6b014c3f3ef590a2cc7e8
SAS
2,048
69
%macro Append_Selected_Data_In_Lib(lib,excel,excluded,add_dsd_name,dsd_not_contain_rgx,dsdout); %let re=%sysfunc(prxparse(s/ /" "/oi)); %let rm_list=%sysfunc(prxchange(&re,-1,&excluded)); %let n_rgx=%eval(%sysfunc(count(&dsd_not_contain_rgx,%str( )))+1); %syscall prxfree(re); proc sql noprint; create table temp...
a78b0d7954e53db24eec0089182470605b88b6b4d811b3d30b869aeb1f9d1c4c
SAS
2,054
64
%macro NOf(vars=, calculated=); %local i v mv mc n; %local calculated allvars; %if %length(%superq(vars)) eq 0 %then %let mv = 0; %else %let mv = %ntokens(&vars); %if %length(%superq(calculated)) eq 0 %then %let mc = 0; %else %let mc = %ntokens(&calculated); %if &mv eq 0 and &...
5734d7961cc89d00251a2c85aa2f4268bb6f6477bcdcda0f9aa200123371449b
SAS
2,065
72
%macro Make_Proc_Import_Code(abs_data_file_name,sas_code_file,kept_variables,getnames_yes_no,datarow,dbms); proc printto log="SAS_Import_Codes.sas" new; run; filename exTemp temp; data _null_; infile "&abs_data_file_name" firstobs=1 obs=1001; file exTemp; input; put _infile_; run; proc import datafile=exT...
f64e5b964c5fe1302555c96bddcf220bb05f4019e6286cd240e31ad2a828eeb0
SAS
2,106
94
%macro split_wide_dsd( dsdin, dsdout_prefix, split_num4vars, dsdout4subdsd, delete_original_dsd=1); *Get the total number of vars in a dsd; data _null_; dsdid=open("&dsdin",'I'); tot=attrn(dsdid,'nvars'); call symput('totvars',left(put(tot,12.))); rc=close(dsdid); run; %put Total vars in your dsd &dsdin is &totvars; ...
3fd0dcc69a81c9f15b98d47b18bd0104c630c20acc979231671b4fe2d2fef640
SAS
2,130
57
%macro make_bin_format( bins,/*space separated list, such as 10 20 30 500 or 10..100 500..100; ensure the consecutive numbers use the linker ".."*/ steps,/*space separated steps for these consecutive nums; if there are less number of steps provided compared to the consecutive numbers included in the bins, the macro ...
0c57b0673359083b45bef2e989730e8574e54cebd917d7db4d8e7b485a17b8e3
SAS
2,140
76
*options nosource nomprint nomlogic nosymbolgen; %macro reorder_cols(dsn); /* Get the variables names to a dataset using proc contents and keeping the variable name only */ proc contents data=&dsn out=varnames(keep=name) noprint; run; /* It is very much important that you UPCASE or LOWCASE the variab...
854602e9546b844b88c943820b39c500374322df8014949e80109aac1df1cdeb
SAS
2,148
84
%macro sorted_boxplots( grpdsd=, /*input dataset for making sorted barplots by the values of a grp variable*/ grp_var=ID, /*character groups for x-axis*/ by_var=count, /*Numeric values for sorting bars and values on y-axis*/ label4grp_var=ID, label4y=Count,/*Y-axis label*/ stat4sort=mean, /*mean, sum, median valu...
7e83f15203024ec5c262c73fea8489a9fe7b6973e367853ce75aae0584df1702
SAS
2,159
104
%macro mkdir(dir); %let count=0; %let dlm=/; %let dir=%sysfunc(prxchange(s/\\/\//,-1,&dir)); %if %quote(%substr(&dir,%length(&dir),1)) ^= "&dlm" %then %do; %let dir=&dir&dlm; %end; %do j=1 %to %length(&dir); %let subdir=%substr(&dir,&j,1); %if "&subdir"="&dlm" %then %do; %let count=%eval(&count+1); %end; %end; %put...
4b1ec8c88767f72029c5c1098ea00f73591e67b9e342d715fa95722c2078b2c3
SAS
2,161
73
/* Apply variable names, labels and formats from dataset indsd to target_dsd */ *options mprint; %macro Rename_Add_Prefix4Most_Vars(indsd,prefix,excluded,replace_rgx_in_varname=); *The macro requires to have the input dataset in the format of lib.dsd; *Note: ensure the excluded vars are in exact lowercase or upper...
62b4ee15f549005cd471a9b577f8c3c40d02d299dd9e69e9867340894ddf0bab
SAS
2,161
90
%macro ImportVarscanRst(filenames,dsdout,Reads4tumor); *Read cutoff of tumor reads; *Only applied to snp but not indel; %if &Reads4tumor eq %then %do; %let Reads4tumor=10; %end; %let i=1; %let fn=%qscan(&filenames,&i,%str( )); %do %while (%qscan(&filenames,&i,%str( )) ne); /*%let outdsd=%sysfunc(prxchange(s...
8ea6113ab2625ed146ed0534f7fa8198375531a4f2a1ff639dd371017a668334
SAS
2,169
69
%macro CheckHeader4GZ_URL( any_gz_url=, infile_cmd=%str(firstobs=1 obs=max;input;info=_infile_;), /*Provide command like the following using the macro str to wrap it; Note: ensure there is not infile put before any supplied infile_cmd, as the infile statement is hard-coded into the internal macro! */ outdsd= )...
b72fd264defe15299c3ef9c76fed7e1579a17701a6e03cb2777014c81ceccdbd
SAS
2,174
66
%macro make_gz_fileref( zip=,/*full path for the gz file*/ outgzfileref=fromzip /*A fileref for the uncompressed zip file*/ ); %if "&sysscp"="WIN" %then %do; *Need to use 7zip in Windows; *Uncompress gz file; *Actionable command: 7z e B1_vs_B2.zscore.txt.gz -y; %let _gzfile_=%scan(&zip,-1,/\); *need to ...
f8d5603dc58b60cf12fc2541b6405f15834a7a233cc337f4ad36d7854e1fe023
SAS
2,186
44
/* / Program : quotelst / Version : 1.0 / Author : Roland Rashleigh-Berry / Date : October 2002 / Contact : roland@rashleigh-berry.fsnet.co.uk / Purpose : To quote the elements of a list / SubMacros : none / Notes : This is useful to turn a list into a quoted list so that you can / use t...
d639d287f6f8937ebb52f307af057d0493da9bf9b69f5a6ff38222abc5c46c4d
SAS
2,223
93
%macro pull_list_by_idx( /*This macro is very useful for pulling elements by using its position index in a lit!*/ list=,/*Blank space separated elements*/ index4list=idx4list, /*index for elements in the list to be extracted*/ sep=%nrbquote( ), /*separator for the input list*/ outlist=_outlist_, /*A global macro v...
cd15486e4d38ce879e5ba21cd397979a2f84a9a48102b90515a738b0eb460fc8
SAS
2,227
86
%macro additive_geno2alleles( indsd=,/*Input sas dataset containing additive genotypes, such as 0, 1, and 2*/ snp_varnames=, /*The order of snp varnames will be used to generate allelic columns in the same order*/ othervars2keep= ,/*Other potential pheno or covariant vars to be kept*/ sample_id=,/*varname for samp...
455ff5aba3fda445074fc29fd3e18ae44dbaf95cd4ed55a086429bc924389eb7
SAS
2,236
89
*options mprint macrogen mlogic symbolgen; *See SAS PDF SAS Macro to back up files across Multiple Directories.pdf for more details.; %macro copyfiles(num); proc sql noprint; select filename into: name from filenames where ord=# quit; options noxwait; %local rc fileref ; %let rc = %sysf...
3da76ce65d8ca4df672cabf21342d8407d7a79cef5717f8476f04d4e9f73ac52
SAS
2,253
117
%macro gnomAD_snp_frq_analyzer( gnomAD_file,/*copy gnomAD Population Frequencies table and save it into a txt file*/ gnomAD_snpid,/*such as 10-63699895-A-C for parsing ref and alt alleles*/ dsdout=gnomAD,/*Output sas dsd*/ csvout=gnomAD /*csv output name without appendix of .csv*/ ); *Get ref and alt alleles; %let ref...
a8a1fad472d013c40a9ba466d33b584e4527b8e85a05bd5d0dbddd880b6faf76
SAS
2,258
58
%macro mhodds(indata,outdata,level); /********************************************************/ /* Compute the odds ratio for each study */ /* (1) Compute Mantel-Haenszel odds ratio and log odds */ /* ratio. */ /* (2) Compute the large sample variance e...
7d270f2a253c1915e61328ceaea04059b20744f2c6946361a93b8e32dcd7cadf
SAS
2,268
96
%macro bed4seriesplot(dsdin,chr_var,st_var,end_var,othervars4keep,dsdout); data _bed4series_; set &dsdin(keep=&chr_var &st_var &end_var &othervars4keep); array X{2} &st_var &end_var; do i=1 to 2; pos=X{i}; ord=_n_; output; end; drop i &st_var &end_var; run; proc sql noprint; select max(ord) into: tot_...
6fc6c687006f333da187f9164b348ea00a4f730586b64c6d07cf7fb37bfb9006
SAS
2,269
52
%macro wavgodds(indata,outdata,intype,level); /********************************************************/ /* INDATA: The output data set from SAS MACRO COMPODDS */ /* INTYPE: Type of log odds ratio to be combined */ /* INTYPE = 1 for combining log odds ratio */ /* INTYPE = 3 for combining am...
f9cc2bc720dda3da797a1661831bcd5ec65a0698fcf0289020b8832172ae5336
SAS
2,273
98
*options mprint; %macro Append_DataSets_In_Lib(lib,excel,excluded,add_dsd_name,dsd_not_contain_rgx,dsd_contain_rgx,dsdout); %let re=%sysfunc(prxparse(s/ /" "/oi)); %let rm_list=%sysfunc(prxchange(&re,-1,&excluded)); %syscall prxfree(re); proc sql noprint; create table temp_xyz as select * from dictionary.ta...
d8197313efa2de73a05cf487298e9c82c9009192a5669d4d4af86ce6e54d0a2c
SAS
2,298
60
%macro MergePlinkBeds(Plink_EXE,BaseBed,OtherBed2Merge,OutBed,DelTmpFiles); /* *Doesn't work, as some dup snps are not excluded by using plink command --list-duplicate-var; %RmDups4PlinkBed(Plink_EXE=&Plink_EXE,PlinkBed=&BaseBed,OutBed=&BaseBed.X); %RmDups4PlinkBed(Plink_EXE=&Plink_EXE,PlinkBed=&OtherBed2Merge,OutBed=...
d973163b604d6110461a0fb2d7ab98fe96cd76fa2ae7d18c275833c0133537e3
SAS
2,310
99
%macro importallmacros(/*Note: multiple dirs can only be separated by blank space and put in a single line!*/ MacroDir=/zcheng/Macros ~/shared/Macros ~/SAS-Useful-Codes/Macros /LocalDisks/F/360yunpan/SASCodesLibrary/SAS-Useful-Codes/Macros H:/F_Queens/360yunpan/SASCodesLibrary/SAS-Useful-Codes/Macros, fileRgx=...
b72a8492db6f64695f764cd84177e3d4ddf4f52d24ee6b1d6714e9f90c844c22
SAS
2,326
88
%macro Query_LargeRangeDsd_With_Idx(base_db, num_key4range_in_base, st4range_in_base, end4range_in_base, query_dsd, num_key4range_in_query_dsd, Pos4lookup_in_query_dsd, out...
be7326dbb1b2ab38466bc6758b3c1a952b47d27565c286f260ee36fec5b562c8
SAS
2,357
85
/** @file @brief Creates a zip file @details For DIRECTORY usage, will ignore subfolders. For DATASET usage, provide a column that contains the full file path to each file to be zipped. %mp_zip(in=myzips,type=directory,outname=myDir) %mp_zip(in=/my/file/path.txt,type=FILE,outname=myFile) %mp...
876b9318505cfd58478f904dc5a1940958d2cf6525f1aa3008ba1f2d55683693
SAS
2,361
72
%macro grep_keyword_in_gzfile(/*Only return the 1st matched record*/ /*If no https in the url, the macro assumes that the input would be a local gz file; if the input file does not contain .zip or .gz, it still can grep it by treating the file as a plain text file!*/ gz_url=https://storage.googleapis.com/covid19-hg...
dd7a8ed59ccb433148ea6dc61672158957a7f29235431a85cfd481fce9264763
SAS
2,369
54
/* ----------------------------------------------------------------------- Program : SizeIt.sas Purpose : Generates GOPTION HSIZE and VSIZE lengths given XMAX and YMAX from PROC GDEVICE. This macro corrects text and shape distortion that occurs when grap...
88bb244c7878129985a80cf19f5ef2e9463e79afb7be89a2c1debcdf0f45224e
SAS
2,372
101
%macro ucsc_cell_matrix2longformatdsd( gzfile_or_url, dsdout4headers, dsdout4data ); %if %eval(%sysfunc(prxmatch(/http.*gz/i,&gzfile_or_url))=1) %then %do; *Download exp matrix gz file; *In SAS ondemand, putting data into the temporary work directory will not be limited by the 5GB quota!; %dwn_http_file(httpfile_ur...
ba3518be71ab37e76b17e647ff7acb6afcd4315a37a1fe823a97dd364e6b254f
SAS
2,384
92
%macro QueryHaploreg(/*Query Haploreg4 for each input SNP to get genes close to it!*/ rsids=rs2564978 rs17425819, dsdout=results, print_html=0 /*Print out the annotations of query SNP(s)*/ ); %do _gi_=1 %to %ntokens(&rsids); %let rsid=%scan(&rsids,&_gi_,%str( )); %let query_url=%nrstr(https://pubs.broadinstitu...
233b47757e0aa1d25cbcc788eaed9604ddbd6e7e5c1a1fad98824e4cb4b49251
SAS
2,388
76
/* MACRO %GetVarOrder Version: 1.01 Author: Daniel Mastropietro Created: 10-Mar-01 Modified: 15-Jan-03 DESCRIPTION: This macro returns the order in which the variables appear in a dataset. USAGE: %GetVarOrder(data , _order_); REQUESTED PARAMETERS: - _data_: Input dataset. It can contain additional opti...
c74b3e7c78c2436fd389faacfa9501a8298a6f6861c740ab565740aca50257f7
SAS
2,393
75
%macro umap_with_axes_restriction( dsdin=new__tgt_dsd_,/*will generated by the macro sc_scatter4gene*/ umap_width=800, umap_height=400, lattice_or_not=0, raxis_max=20000, raxis_min=0, caxis_max=, caxis_min=45000, panel_row_num=1, /*The value will be assigned to rows in proc sgpanl for the panel statement; whe...
cdd679a1196f2518b80814b3cd2e363bac8b0877b11851d72c79a17d0bef8495
SAS
2,414
101
/* In macro DataReplacement dsd => target dsd subjects to replacement vars2replace => variables to be replace with specific data; if it is empty, will select all variables (either numeric or character) var_type => numeric or character filter4replace => regex to match word...
935b511608b164825cbb38e6ef5accc047901e89aa3a1d7cf3a4ff973a8fef25
SAS
2,431
76
%macro unique/parmbuff; %let i = 1; %let w1 = %scan(&syspbuff,1); %do %while (&&w&i ne ); %let i = %eval(&i + 1); %let w&i = %scan(&syspbuff,&i); ...
e6b05df4706b29a2142899a3879b155089f162af65411df2c4658e6f2bdd7ff4
SAS
2,436
73
%macro fasta2sas(/*It is able to read a fasta file containing multiple fasta records*/ fasta, outdsd, fasta_one_line_mode=1 ); filename fasta "&fasta"; %if &fasta_one_line_mode %then %do; data &outdsd; infile fasta end=done; length desc $1000. sequence $32767.; /*Create number to determin when to output con...
d3156bd60aaf03e17df5e2ef77d70ce063cd669290a707847009d191a7ebafba
SAS
2,439
98
/** @file mp_unzip.sas @brief Unzips a zip file @details Opens the zip file and copies all the contents to another directory. It is not possible to retain permissions / timestamps, also the BOF marker is lost so it cannot extract binary files. Usage: filename mc url "https://raw.githubuser...
bc454ee470ce080e4b787fc5c0d6a8d7392f3454083266fa00b67a16e09460a3
SAS
2,481
76
%macro mult_columns_linker_by_grp_var( indsd=_last_, outdsd=Linked_dsd, grp_var=,/*This var will be treated as key for linking all elements among var2link; Note: only unique element will be kept by the macro*/ vars2link= ,/*separate multiple CHAR vars by space or use var1-varn but not varA--varB to include multiple...
f9c3cf1b9d6e82ed2b39e414be15d9e9b1bd740fa0adb71f8305ce35db0ba978
SAS
2,492
76
%macro rename_cols_with_macro_vars( /*Function annotation: this macro is good for renaming large number of columns without trunction in a macro var; Pleade use symputx('mvname',value,'G') to make global macro variables for this macro; */ totcols, dsd, colvar_prefix, macro_var_prefix ); data &dsd; set &dsd; *...
1b539b422944bdd54c89e24a07bfe69c68710d58eb7f3a0ee7fcf5e6d352890d
SAS
2,498
95
%macro union_add_tags(dsds=, /*Name of the datasets, separated by space */ out= /*Name of combined data set */); %local vars_all_numeric nobs; %let vars_all_numeric=0; %let i=1; %do %while(%scan(&dsds,&i,%str( )) ne); %let f=%scan(&dsds,&i,%str( )); %put going ...
6bfe34d45c63b36666cc4e5a8bfa4700b899ab856e4f1a95e38a10fb7772105a
SAS
2,536
62
*options nodate nocenter pagesize=54 linesize=80 pageno=1; %macro homeodds(indata,outdata,type,initial); data; set &indata; /*******************************************************/ /* Compute the chi-square test statistics for the */ /* homogeneity of common odds ratio based on Breslow */ /* and Day (1980...
16057f336c09095c89ef40f3df19857f35433ec8dad1352d777c52e5f38e95f5
SAS
2,586
99
*Note: this macro will generate; *double quoted list for the function 'in' for filtering in data step; *the final list will be saved into macro var(s) with specific prefix; %macro select_elems_range_from_dsd( dsdin=, keyvar=,/*var subjected for making list*/ split_by_fold=0,/*Provide value >1 to separate elements into ...
86b70ae35ec2e048cef17f05179944488515cdf5bc3eca25adf13bbcc6ccb4cd
SAS
2,596
84
%macro SumOf(vars=, calculated=); %local dim i v mv mc n; %local calculated allvars; %if %length(%superq(vars)) eq 0 %then %let mv = 0; %else %let mv = %ntokens(&vars); %if %length(%superq(calculated)) eq 0 %then %let mc = 0; %else %let mc = %ntokens(&calculated); %if &mv eq 0...
98da86d7652716e7e995b5855477c36e9d8338591d9c25a347219b3d3cc3c07f
SAS
2,599
47
/** SAS Macro to add a prefix to some or all variables in a data set... to be used like this... %prefixvars(inpdsn,prefix,outdsn,excludevars=); inpdsn - input dataset name libname.dsnname prefix - prefix that you want to assign outdsn - output dataset name libname.dsnname excludevars - vars that you do not want ...
dab42f6c2d2b9b67e97d41e8e38359cce3ebfd84bf9c17b6fb0884711a9c8a04
SAS
2,641
78
%macro UncompressGZWith7ZInWindows( gzfilepath=,/*fullfilepath for gz file*/ globalvar4finalfile=final_gz_file /*Provide a global macro var name to access the uncompressed file later by other macros*/ ); %global &globalvar4finalfile; *Assign missing value for the global var; %let &globalvar4finalfile=; %le...
ca3f86cbecd34cb82837679a1e9daa7c43c645993052bdcd881e329bf525baee
SAS
2,642
111
%macro map_assoc2gene4covidsexgwas( gwas_dsd=FM.f_vs_m_mixedpop, gtf_dsd=FM.GTF_HG19, chr=, min_st=, max_end=, AssocPVars=pval gwas1_p gwas2_p, ZscoreVars=diff_zscore gwas1_z gwas2_z ); %let totP=%sysfunc(countw(&AssocPVars)); %if &totP ne %sysfunc(countw(&ZscoreVars)) %then %do; %put Please make sure the two macro...
4b5e03ea04fcc6d11c6c0843d2cc33af55b25e7efb720a89343d64046d5f3abc
SAS
2,668
99
%macro add_symbol4grp_in_dsd(dsdin,grp_var,symbols,dsdout); proc sql; create table grp_var as select unique(&grp_var) from &dsdin; data grp_var; set grp_var; symbol_grp=scan("&symbols",_n_,' '); if symbol_grp="" then symbol_grp='X'; run; proc sql; create table &dsdout as select a.*,b.symbol_grp from &dsdin as a, ...
4e1f051972bbeb156ea1dff543a5db2cee2ddb41c3b188c36a161be6af73919b
SAS
2,716
69
/********************************************************** * Macro for grouping continuous variable into quantile4dsdiles. * * The macro requires three input variables: * * dsn: data set name * * var: variable to be categorised * * quanti...
8574b53e0370dfa828ce01b50aed3fee4f7d0160e6922e4d80dda4f0f963407f
SAS
2,719
146
%macro SortDsd4Plot(dsd,ByFmtVar,OutFmtVar,OutDsd,GroupVars,SumByVar,CountByVar,MeanByVar); %if &GroupVars ne %then %do; proc sort data=&dsd; by &GroupVars; run; proc rank data=&dsd out=_dsd_; var &ByFmtVar; ranks rank_&ByFmtVar; by &GroupVars; run; proc sort data=_dsd_; by &GroupVars rank_&ByFmtVar; run;...
a8db0824dde69e0910ec17c5a0670e3639bd83f7de8ee0f2dc95c38a5df928d5
SAS
2,720
80
/* MACRO %GetVarNames Version: 1.01 Author: Daniel Mastropietro Created: 15-Jul-03 Modified: 23-Sep-03 DESCRIPTION: Devuelve en una macro variable la lista de variables de un cierto tipo (numéricas, caracter o todas) presentes en un dataset. USAGE: %GetVarNames(data , var=_ALL_); REQUIRED PARAMETERS: -...
a6935be91c156e5dcf258864808016771a7ec6b555e23ee6809560b9da7bb642
SAS
2,731
84
%macro leftalign4catstr(/*Note: the final generated combinedVar can be used by proc sgplot with the xaxis valuesrotate=diagonal2 for best visual effect*/ dsdin=, vars4cat=, /*vars separated by blank spaces in order for catx*/ combinedVar=combined_vars,/*A new variable containing combined vars by catx*/ add_extra_...
5b1fbcdf9c598c04d182c8991676d26a93d9bfa613bdaaaf420e59ec5cfe53ce
SAS
2,745
79
%macro range2consecutive_num( arg,/*input nums separated by space and '-' or other customized linker using perl regular expression is applied to link consecutive numbers, such as 10-300 or 10..300; note: when using customized linker rather than "-", do not include "-" in the input arg!*/ step=1 1 1, /*single or mul...
0cd0f6ac24c91321e3ac5a7e8443083e776417979e11810860ebaf3702fc8199
SAS
2,751
106
%macro MatlabMatrix4SAS(Matrix_File,Rowlabels_File,Collabels_File,dsd_out,Matrix2Num); /* %let tmp_dir = %sysfunc(getoption(work)); %let outfullpath=%str(&tmp_dir/Proc_Import_Template.sas); %Make_Proc_Import_Code(abs_data_file_name=&Matrix_File ,sas_code_file=&outfullpath ,kept_v...
462c3471f611d0b80f002dd34ca90885b92b1b12210e5b71728d2b680bad92ba
SAS
2,773
90
%macro make_heart_pict( heart_color=pink, non_heart_area_color=lightgreen, pict_width_inch=10, pict_height_inch=10 ); *If want to draw a circle, just replace x and y with x=sin(t) and y=cost(t); *if want to draw a beet-like shape, just use x=sin(t)**3 and y=cos(t); data heart; pi = constant('PI'); d...
88c16629f15e38381bcd1c6c38f0b30d3ef0f08e6ab00090912dad2e7b3f2812
SAS
2,809
127
%macro LinkDupWithHash(dsd,keys,values,out_var_names,linker,outdsd,rmdups); *Link the duplicates for the key in a dsd; *Will output unique key and its values (linked with specific separator) into outdsd; *Change all empty cells into NaN; %RepRegx2ValueInDsd(&dsd,&dsd,s/^\s*$/NaN/,0); %let new_keys=%quotelst(...
efb5a4f0f9605364a34d1485e431d0bb5c96bb910ec2e3cb11f3159fcf6f3919
SAS
2,842
90
%macro FilterFile( filefullpath /* input file fullpath */ ,ExcludedLineRegx /*Lines will be excluded if match the regexpression */ ,KeptLineRegx /*Lines will be kept if match the regexpression*/ ,system /* The system to run the mac...
faa3fed7b3751e7b1b2d0a88843d10e0dfb3f68ac9d6bdb724a7006f184a5f97
SAS
2,846
85
%macro match_elements_in_macro_list( macro_list=,/*elements should be separated by blank space*/ rgx4match=,/*regular expression of prxmatch, such as (rgx1|rgx2)*/ reversematch=0,/*provide 1 to keep elements not matched with the rgx*/ output_idx=0, /*Instead of keeping matched or unmatched elements, keep the 1-base...
081aeed793b2751ff800d451e7bce6f109a5e271b724e3bff895027c99317bc7
SAS
2,872
87
%macro get_HGI_covid_gwas_from_grasp(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); *Uncompress the file in Windows; %if &sysscp=WIN %then %do; %UncompressGZWith7ZInWindows...
6346106d8ff93b1e0f1785d1de1372f3be10e96d679b1b841239e9b700ae5ddc
SAS
2,920
94
%macro MeanOf(vars=, calculated=); %local dim i v mv mc n; %local calculated allvars; %if %length(%superq(vars)) eq 0 %then %let mv = 0; %else %let mv = %ntokens(&vars); %if %length(%superq(calculated)) eq 0 %then %let mc = 0; %else %let mc = %ntokens(&calculated); %if &mv eq ...
d3e8fde5febe45937ae8591efd7cd337a10928c50e1aa276abf485602cdf692b
SAS
2,927
119
%macro Multfiles2Matrix(file_dir,flrxp,tgt,value,value_type,value_cutoff_formula,matrix_dsd,debug); %get_filenames(location=%bquote(&file_dir),dsd_out=filenames); %if &debug=1 %then %do; %ImportFilesInDSDbyScan(filedsd=filenames ,filename_var=memname ,filedir=&file_dir ...
f8b37d0fbffcebde6123ac5f9223311fdddff281a5d40b8d290e5a7b5a3f1877
SAS
2,932
110
%macro ImportTXTFromZIP(zip,filename_rgx,sasdsdout,extra_proc_import_codes,deleteZIP); %local nfiles txtfilenames txtfilename; %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 %...
0742b52c6d807d69aba6462c069cadee112369b259b523b34ca2b36ebfc22e86
SAS
2,976
76
*https://sesug.org/proceedings/sesug_2024_SAAG/PresentationSummaries/Papers/151_Final_PDF.pdf; *options mprint mlogic symbolgen; filename M url "https://raw.githubusercontent.com/chengzhongshan/COVID19_GWAS_Analyzer/main/Macros/importallmacros_ue.sas"; %include M; Filename M clear; %importallmacros_ue(MacroDir=%sy...
21b29753de1d6b79d928947417dee543261295908440c9c65e4005dcd718abdf
SAS
2,985
98
%macro Auto_char2num4dsd( dsdin /* input dsd */ ,col_num_pct /*such as 0.8, indicating percentage of rows is numberic, used for selection of col to be change it into numeric*/ ,dsdout /* Output dsd */ ) ; /* PURPOSE: aut...
4002a4de0937d3c6226cbe387ee99c9f7b51454bddbd17fa5acd074a6a9d4bc2
SAS
3,010
106
%macro sorted_boxplots4multgrps( grpdsd=, /*input dataset for making sorted barplots by the values of a grp variable*/ grp_var=ID, /*character groups for x-axis*/ subgrp_var=SubID,/*subgrp variable for boxplot cluster at each x-axis group variable*/ by_var=count, /*Numeric values for sorting bars and values on y-ax...
1c594abb9873ad8c971c8f3d4c3a809455628b37ffc2fef23afc6b5285e62870
SAS
3,019
119
/* https://en.wikipedia.org/wiki/Quantile_normalization */ %macro Quantile_normalization(data, var, out, ties=LOW); %local rn nv i n_obs var_r arr_r ; %let rn =zjk79x_; %let nv =%sysfunc(countw(&var)); %do i =1 %to &nv; %let var_r =&var_r &rn.r%sysfunc(putn(&i, z3.)); ...
20ed46da95de8254fcbdbfba9ca04dd22c284fdef4e2c31d096bae389ec3e81c
SAS
3,024
105
/* gwas_names: such as A1_ALL, B1_ALL, B2_ALL, and C2_ALL; Long COVID HGI - DF4 W1 => gwas number 91854 Long COVID HGI - DF4 N2 => gwas number 192226 Long COVID HGI - DF4 W2=> gwas number 826733 Long COVID HGI - DF4 N1=> gwas number 793752 Strict cases of long COVID after test-verified SARS-CoV-2 infection (...