data _null_ ; long='dog cat rat bat dog camel dingo snake bigdog' ; num_dog=count(long,'dog') ; put num_dog= ; run ;
Tag Archive for count
Count up the number of characters in a string
Count up the number of substrings in a string
data _null_ ; long='a b c d a e d a e t g d a c s' ; num_a=countc(long,'a') ; put num_a= ; run ;
YUI Compressor break before 8000 characters so as not to break ClearCase
java -jar yuicompressor-2.3.3.jar script_to_minify.js --nomunge --line-break 7999 -o minified.js
Category: Uncategorized |
Tags: 8000, bug, clearcase, compress, count, css, javascript, line, minify, optimization, performance, yui
Dump a file to the terminal, starting at some line number
tail -n+99 foo.txt | more
Word Count 2
%macro nwords(s); (compress(&s) ne ' ') * (length(left(compbl(&s)))-length(compress(&s))+1) %mend nwords; data _null_; string = "dasj h 07y lk0 - ldsmv"; nwords = %nwords(string); put nwords=; run; /*NWORDS=6*/
Word Frequency Count
/* test data set */ data comments; length obs 8 comment $1000.; length p 8 c $1.; drop p c; input obs @@; /* skip the blanks */ do while (c=''); input c $char1. @@; /* guess what is wrong with $1.? */ end; /* read one char at a time */ p = 1; substr(comment,p,1) = c; do until (c='#'); p + 1; input c $char1. @@; substr(comment, p, 1) = c; end; substr(comment, p, 1) = " "; /* get the # out */ /* release the input line */ input; cards; 1 SAS defines analytics as data-driven insight for better decisions. With SAS Analytics you get an integrated environment for predictive analytics and descriptive modeling, data mining, text mining, forecasting, optimization, simulation, experimental design and more.# 2 Our analytic solutions provide a range of techniques and processes for the collection, classification, analysis and interpretation of data to reveal patterns, anomalies, key variables and relationships, leading ultimately to new insights for guided decision making.# 3 We offer a comprehensive suite of analytics software# 4 SAS offers an integrated suite of analytics software unmatched in the industry, and delivered to you in a single environment.# ; run; /* parse each word into an obs */ data words; length obs no 8 word $16.; /* will be truncated if longer */ keep obs no word; set comments; no = 0; do while(1); no + 1; word = upcase(scan(comment, no, " .,!?")); if word="" then leave; output; end; run; proc freq data=words; tables word/ out=counts; run; data test; set counts; file print; if word>='A'; n + 1; drop n; if mod(N,3)=1 then put; /* changed to 3 to narrow */ put word $10. count 5. +3 @; run;
Get the length of a string on the command line with Ruby
ruby -e "puts 'length of this string'.length"
count htm/html files in the directory (recursive)
ls -R | grep -c '.htm'
PHP æ–‡å—を切り出ã™
$substr_test1= "日本語ã§ã™"; $substr_test2 = "English"; $substr_test3 = "日本語English"; //ãƒã‚¤ãƒˆæ•°ã‚’指定ã—ã¦æ–‡å—列をå–り出ã™ã€‚ print substr( $substr_test1, 2, 2 ) . " "; //本 print substr( $substr_test2, 2, 2 ) . " "; //gl print substr( $substr_test3, 8 ) . " "; //glish //ãƒã‚¤ãƒˆæ•°ã‚’指定ã—ã¦æ–‡å—列をå–り出ã™ï¼ˆå³å´ã‹ã‚‰ï¼‰ã€‚ print substr( $substr_test1, -4, 2 ) . " "; //ã§ print substr( $substr_test2, -4, 2 ) . " "; //li print substr( $substr_test3, -4 ) . " "; //lish //æ–‡å—æ•°ã‚’指定ã—ã¦æ–‡å—列をå–り出ã™ã€‚ print mb_substr( $substr_test1, 2, 2, 'UTF-8' ) . " "; //語㧠print mb_substr( $substr_test2, 2, 2, 'UTF-8' ) . " "; //gl print mb_substr( $substr_test3, 8, 'UTF-8' ) . " "; //sh //æ–‡å—æ•°ã‚’指定ã—ã¦æ–‡å—列をå–り出ã™ï¼ˆå³å´ã‹ã‚‰ï¼‰ã€‚ print mb_substr( $substr_test1, -4, 2, 'UTF-8' ) . " "; //本語 print mb_substr( $substr_test2, -4, 2, 'UTF-8' ) . " "; //li print mb_substr( $substr_test3, -4, 3, 'UTF-8' ) . " "; //lish
MySQL count rows
<?php
// connect to the database first
dbconnection();
// query
$result = mysql_query("SELECT * FROM tablename");
$rows = mysql_num_rows($result);
// results
echo $rows;
?>