ndmetcal All American 9012 Posts user info edit post |
Trying to make a table comparing school quality to zip code (using proc freq)
The school quality is measured by the numeric variable Stars (1-5) & the zip code is the basic 5 digit zip. However, since the 5-digit zips are too narrow, I want to use the first 3 numbers of the zip codes for a broader comparison
I'm at a loss for how to read in the 5-digit zip code but then chop it to 3-digits for this table (want it to stay 5 digits everywhere else)
Suggestions? 2/24/2011 4:53:45 PM |
ndmetcal All American 9012 Posts user info edit post |
Nevermind, I got it 2/24/2011 5:54:33 PM |
wwwebsurfer All American 10217 Posts user info edit post |
2/24/2011 7:28:29 PM |
lewisje All American 9196 Posts user info edit post |
something like ZipArea=(ZipCode-(ZipCode%100))/100
[Edited on February 24, 2011 at 7:50 PM. Reason : or if there is an integer type with no implicit casting of integer division, ZA=ZC/100 2/24/2011 7:48:49 PM |
ndmetcal All American 9012 Posts user info edit post |
just did zip3=put(zip, 3.); 2/24/2011 9:21:32 PM |
Gonzo18 All American 2240 Posts user info edit post |
I think you can use the substring function. New_zip = substr(zip,1,3); That basically says take the first 3 characters of the original variable and create a new variable called new_zip. 2/24/2011 10:08:52 PM |
philihp All American 8349 Posts user info edit post |
zip3=put(zip, 3.);
that's what i would have done too. 2/25/2011 10:49:24 AM |
Gonzo18 All American 2240 Posts user info edit post |
This will work as long as you define zipcode as a character variable, not numeric.
data zips; input zip5 $; zip3=substr(zip5,1,3); cards; 12345 23456 34567 ;
run;
proc print data=zips; run; 2/25/2011 3:08:30 PM |
Jrb599 All American 8846 Posts user info edit post |
You wanna use substrn, but it can be a numeric.
data zipset; set zipset; zip3=substrn(zip5,1,3); drop zip5; RUN;
[Edited on February 25, 2011 at 5:31 PM. Reason : ] 2/25/2011 5:28:33 PM |
evan All American 27701 Posts user info edit post |
put(zip, 3.); would also have been my answer to this question
ibtl 2/25/2011 7:11:35 PM |
philihp All American 8349 Posts user info edit post |
You might consider creating a web service to handle this, since the functionality is so controversial, that way the implementation is abstracted away and you can write it in a language you're more comfortable in.
As long as you have a well-formed WSDL file for the web service, SAS 9 has some powerful web service procedures that you can use to implement calls. 2/28/2011 11:55:11 PM |
pttyndal WINGS!!!!! 35217 Posts user info edit post |
ttt 2/21/2012 12:49:29 PM |
Klatypus All American 6786 Posts user info edit post |
btt 2/21/2012 12:52:50 PM |
MinkaGrl01
21814 Posts user info edit post |
bttt 2/21/2012 12:53:30 PM |
rtc407 All American 6217 Posts user info edit post |
sweet.
So how long should a proc tabulate summary table take with ~4.5mil records?
I'm trying to make a pivot table basically but it has been running about an hour. Running on 1 core at 2.53 GHz, right now at about 500MB/12GB ram.
If it's never going to finish I'll go ahead and kill it but I don't have any idea how long it should take. 2/21/2012 1:22:17 PM |
Shivan Bird Football time 11094 Posts user info edit post |
I would've guessed 3 minutes. Try it with a smaller table. You can do something like "proc tabulate data=something(obs=1000)" 2/21/2012 6:53:22 PM |
Jrb599 All American 8846 Posts user info edit post |
I can usually do 300 mil records in an hour 2/22/2012 7:39:10 AM |
rtc407 All American 6217 Posts user info edit post |
I just went back to Access and did a crosstab query. I must have set something up wrong in SAS b/c it froze up after about 4 hours, whereas its only 10 min from import in Access to export in Excel. 2/22/2012 11:53:43 AM |
EMCE balls deep 89771 Posts user info edit post |
TTT, B. 6/5/2012 6:41:49 PM |
rtc407 All American 6217 Posts user info edit post |
^thanks
coming back to this thread with a little more experience but probably just as idiotic of a question.
have a macro that creates a bunch of speed datatables with a datetime and speed column. I want to create an index time table with all possible datetimes between the first and last in the entire dataset so I can merge all the tables together and have rows of blank speeds when none of the speed tables report a speed.
tl;dr: given a start and end datetime and an interval in minutes, I need a table with all times between in a single column.
here's what I've got so far:
proc sql noprint; select min(time) into :mintime from inrix;
proc sql noprint; select max(time) into :maxtime from inrix;
%let obs=%eval(
proc sql noprint; create table timeindex (time date format=datetime.);
%let timer=&mintime;
%do %while(&timer<=&maxtime);
proc sql noprint; insert into timeindex set time=&timer;
%let timer=%eval(&timer+%eval(&interval*60));
%end;
It seems to work when I put an integer in for mintime and maxtime in a test macro (extremely slowly), but says
Quote : | "A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 1.6356E9+60" |
when run within the whole macro. I'm guessing the first two proc sql statements are formatting the variables into dates, but I don't know how to fix that. Plus, the condition quoted looks like two numbers to me.
[Edited on June 5, 2012 at 7:29 PM. Reason : .]6/5/2012 7:27:16 PM |
Gonzo18 All American 2240 Posts user info edit post |
Try posting your question herehttps://communities.sas.com/community/support-communities/sas_macro_facility_data_step_and_sas_language_elements 6/5/2012 8:20:26 PM |
rtc407 All American 6217 Posts user info edit post |
Looks like I was definitely getting ahead of myself attempting awesome macros and sql inserts
This:
data timeindex; do time=&mintime to &maxtime by %eval(&interval*60); output; format time datetime.; end; run;
worked extremely quickly. I tried this originally but left out the do part of the statement so I figured it wouldn't work.6/6/2012 12:37:21 AM |