I am working with proc http , I've developped this code and run it , no errror !
filename csvfile TEMP;
proc http
method="get"
out=csvfile
url="https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv" ;
run;
But when I try to print the data, I get this error, someone to help!
PROC HTTP downloads the data file, but does not import it to a SAS data set. For that, use PROC IMPORT or DATA step.
filename csvfile temp encoding='utf8' termstr=CR ;
proc http
method="get"
out=csvfile
url="https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv" ;
run;
proc import file=csvfile
dbms=csv
out=mydata
replace;
run;
proc print data=mydata (obs=10); run;
Please show us the full complete unedited LOG of these two PROCs. Do not chop anything out of the LOG for these two PROCs. Use the </> icon and paste your log as text into the window that appears — DO NOT SKIP THIS STEP.
I requested:
Use the </> icon and paste your log as text into the window that appears — DO NOT SKIP THIS STEP.
PROC HTTP downloads the data file, but does not import it to a SAS data set. For that, use PROC IMPORT or DATA step.
filename csvfile temp encoding='utf8' termstr=CR ;
proc http
method="get"
out=csvfile
url="https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv" ;
run;
proc import file=csvfile
dbms=csv
out=mydata
replace;
run;
proc print data=mydata (obs=10); run;
Thanks CHRIS, but I got this error.
The </> icon is this button:
The "little running man" right next to it is for posting SAS code.
Whoops, I left a hard-coded file path in my code. I changed it now -- use TEMP instead of a real path.
filename csvfile temp encoding='utf8' termstr=CR ;
Thanks so much @ChrisHemedinger , it works perfectly!!!
The </> is much simpler to use, as you need to only copy/paste the text,, instead of attaching a file. And everybody can read the log right there, without downloading or previewing (which often does not work).
@KOUAME wrote:
OK, but as I use SAS STUDIO, I can print it as PDF file. CHRIS gives a solution, just got "Insufficient authorization to access" for his solution.
You downloaded a text file, not a dataset.
To look at the text file you can use a simple data step. For example this code will dump the first 10 lines of the text file to the SAS log.
data _null_;
infile csvfile obs=10;
input;
list;
run;
Now you can see what is in the file and decide how to write a data step to read the file into a SAS dataset.
data want;
infile csvfile dsd firstobs=2 truncover ;
input var1 .... ;
run;
For this file the first thing you will notice is that the lines are using only a CR as the end of line marker.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 gameorder,game_id,lg_id,_iscopy,year_id,date_game,seasongame,is_playoffs,team_id,fran_id,pts,elo_i,e 101 lo_n,win_equiv,opp_id,opp_fran,opp_pts,opp_elo_i,opp_elo_n,game_location,game_result,forecast,notes. ZONE 6656276656776726775662677567662677577726775666562677566656266665666676662666657677672667666772667670 NUMR CFFEC79EF51596CF00F94CF00F621ECF00F043CF00F5CFF9CF00F5CFFEC71D5FCF3149FEC71D5F2535C4C6F253134CEF453D 201 1,194611010TRH,NBA,0,1947,11/1/1946,1,0,TRH,Huskies,66,1300,1293.2767,40.29483,NYK,Knicks,68,1300,13 301 06.7233,H,L,0.64006501,.1,194611010TRH,NBA,1,1947,11/1/1946,1,0,NYK,Knicks,68,1300,1306.7233,41.7051 ZONE 3323333242423233333333203233333333355424442323333233232333323232454246666723323333233332333323323333 NUMR 06E7233C8CCC0E64006501CD1C194611010428CE21C1C1947C11F1F1946C1C0CE9BCBE93B3C68C1300C1306E7233C41E7051
So modify your INFILE statement to use TERMSTR=CR option.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 gameorder,game_id,lg_id,_iscopy,year_id,date_game,seasongame,is_playoffs,team_id,fran_id,pts,elo_i,e 101 lo_n,win_equiv,opp_id,opp_fran,opp_pts,opp_elo_i,opp_elo_n,game_location,game_result,forecast,notes 199 2 1,194611010TRH,NBA,0,1947,11/1/1946,1,0,TRH,Huskies,66,1300,1293.2767,40.29483,NYK,Knicks,68,1300,13 101 06.7233,H,L,0.64006501, 123 3 1,194611010TRH,NBA,1,1947,11/1/1946,1,0,NYK,Knicks,68,1300,1306.7233,41.70517,TRH,Huskies,66,1300,12 101 93.2767,A,W,0.35993499, 123
Now you can just copy and paste that list of column headers from the log and use it to make names for the variables you want create to hold this data. You could use names that match the column headers or make your own names for the variables that make more sense to you.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.