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 comparisonI'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
Nevermind, I got it
2/24/2011 5:54:33 PM
2/24/2011 7:28:29 PM
something likeZipArea=(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
just didzip3=put(zip, 3.);
2/24/2011 9:21:32 PM
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
zip3=put(zip, 3.);that's what i would have done too.
2/25/2011 10:49:24 AM
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;123452345634567;run;proc print data=zips;run;
2/25/2011 3:08:30 PM
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
put(zip, 3.); would also have been my answer to this questionibtl
2/25/2011 7:11:35 PM
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
ttt
2/21/2012 12:49:29 PM
btt
2/21/2012 12:52:50 PM
bttt
2/21/2012 12:53:30 PM
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
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
I can usually do 300 mil records in an hour
2/22/2012 7:39:10 AM
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
TTT, B.
6/5/2012 6:41:49 PM
^thankscoming 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 :mintimefrom inrix;proc sql noprint;select max(time)into :maxtimefrom 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;
6/5/2012 7:27:16 PM
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
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;
6/6/2012 12:37:21 AM