BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KOUAME
Obsidian | Level 7

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!

 
 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 proc print data=csvfile;
ERROR: File WORK.CSVFILE.DATA does not exist.
 run;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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;

 

 

2021-04-27_09-17-36.jpg

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

13 REPLIES 13
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
KOUAME
Obsidian | Level 7
This is the log when I run the http procedure:
 
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 filename csvfile TEMP; /*"/home/u49615496/My Researches/data/csvfile.csv" ; */
74 proc http
75 method="get"
76 out=csvfile
78 run;
 
NOTE: PROCEDURE HTTP used (Total process time):
real time 1.40 seconds
user cpu time 0.12 seconds
system cpu time 0.04 seconds
memory 1481.87k
OS Memory 33188.00k
Timestamp 04/27/2021 12:42:46 PM
Step Count 48 Switch Count 3
Page Faults 0
Page Reclaims 364
Page Swaps 0
Voluntary Context Switches 2380
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 35496
 
 
79
80 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
92
 

 

PaigeMiller
Diamond | Level 26

I requested:

 

Use the </> icon and paste your log as text into the window that appears — DO NOT SKIP THIS STEP.

 
and you skipped that step 😞
--
Paige Miller
KOUAME
Obsidian | Level 7
</>OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 filename csvfile TEMP; /*"/home/u49615496/My Researches/data/csvfile.csv" ; */
74 proc http
75 method="get"
76 out=csvfile
77 url="https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv" ;
78 run;

NOTE: PROCEDURE HTTP used (Total process time):
real time 1.40 seconds
user cpu time 0.12 seconds
system cpu time 0.04 seconds
memory 1481.87k
OS Memory 33188.00k
Timestamp 04/27/2021 12:42:46 PM
Step Count 48 Switch Count 3
Page Faults 0
Page Reclaims 364
Page Swaps 0
Voluntary Context Switches 2380
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 35496


79
80 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
92
ChrisHemedinger
Community Manager

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;

 

 

2021-04-27_09-17-36.jpg

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
KOUAME
Obsidian | Level 7

Thanks CHRIS, but I got this error.

KOUAME
Obsidian | Level 7
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.
ChrisHemedinger
Community Manager

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 ; 
Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
KOUAME
Obsidian | Level 7

Thanks so much @ChrisHemedinger , it works perfectly!!!

Kurt_Bremser
Super User

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.

 

Tom
Super User Tom
Super User

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.

 

 

KOUAME
Obsidian | Level 7
Thanks @Tom

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 13 replies
  • 4639 views
  • 8 likes
  • 5 in conversation