Libref is not assigned

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 112
Accepted Solution

Libref is not assigned

%let dirdata="C:\Users\jc3992\Downloads";
libname snow "&dirdata";
/*1*/
data snow.snowfall;
proc import "&dirdata.snow.sas7bdat";
run;

Hello everyone,

I changed to SAS 9.2 from University Edition because I could not read the full length of a data set by SAS Studio,

thus I am not familiar with setting a permanent library.

I used the code above to import a data set in a sas. file

and the LOG showed this:

77   %let dirdata="C:\Users\jc3992\Downloads";
78   libname snow "&dirdata";
NOTE: Line generated by the macro variable "DIRDATA".
1     ""C:\Users\jc3992\Downloads"
      --
      49
        -
        22

      --
      49
ERROR: Libref SNOW is not assigned.
ERROR: Error in the LIBNAME statement.
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS
             release.  Inserting white space between a quoted string and the succeeding
             identifier is recommended.

ERROR 22-7: Invalid option name C.

79   /*1*/
80   data snow.snowfall;

ERROR: Libref SNOW is not assigned.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds



NOTE: PROCEDURE IMPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.
81   proc import "&dirdata.snow.sas7bdat";
NOTE: Line generated by the macro variable "DIRDATA".
1     ""C:\Users\jc3992\Downloads"snow.sas7bdat
      --
      49
      22
      76
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS
             release.  Inserting white space between a quoted string and the succeeding
             identifier is recommended.

ERROR 22-322: Syntax error, expecting one of the following: ;, DATAFILE, DATATABLE, DBMS,
              DEBUG, FILE, OUT, REPLACE, TABLE, _DEBUG_.

ERROR 76-322: Syntax error, statement will be ignored.

82   run;


May I ask how can I assign the libref snow?

 

Thank you!


Accepted Solutions
Solution
‎03-02-2018 05:41 PM
PROC Star
Posts: 1,769

Re: Libref is not assigned

remove the quotes:

 

 

 %let dirdata=C:\Users\jc3992\Downloads;

View solution in original post


All Replies
Solution
‎03-02-2018 05:41 PM
PROC Star
Posts: 1,769

Re: Libref is not assigned

remove the quotes:

 

 

 %let dirdata=C:\Users\jc3992\Downloads;
Frequent Contributor
Posts: 112

Re: Libref is not assigned

Posted in reply to novinosrin

It worked after I struggled the whole afternoon lol

Thanks so much!!

Frequent Contributor
Posts: 112

Re: Libref is not assigned

Posted in reply to novinosrin
%let dirdata=C:\Users\jc3992\Downloads;
libname snow "&dirdata";
run;

/*1*/
data snow.snowfall;
set "&dirdata.Tmp4.Snow";
Year = INPUT((SUBSTR(Season, 1, length(Season)-3)),4.); 
ARRAY month (10) Sep--Total;
DO i=1 to 10;
if month(i)=. then month(i)=0;
end;
run;

Now the data set is in the Tmp4 file in my dirdata file.

I want to create a graph of the snowfalls for November December January February and March v.s. Year

The part of the data set is as below

snow.jpg

And after I ran the code,

the Log showed as below:

168  %let dirdata=C:\Users\jc3992\Downloads;
169  libname snow "&dirdata";
NOTE: Libref SNOW refers to the same physical library as TMP4.
NOTE: Libref SNOW was successfully assigned as follows:
      Engine:        V9
      Physical Name: C:\Users\jc3992\Downloads
170  run;

171  %let dirdata=C:\Users\jc3992\Downloads;
172  libname snow "&dirdata";
NOTE: Libref SNOW refers to the same physical library as TMP4.
NOTE: Libref SNOW was successfully assigned as follows:
      Engine:        V9
      Physical Name: C:\Users\jc3992\Downloads
173  run;
174
175  /*1*/
176  data snow.snowfall;
177  set "&dirdata.Tmp4.Snow";
ERROR: Extension for physical file name "C:\Users\jc3992\DownloadsTmp4.Snow" does not
       correspond to a valid member type.
178  Year = INPUT((SUBSTR(Season, 1, length(Season)-3)),4.);
179  ARRAY month (10) Sep--Total;
NOTE: The array month has the same name as a SAS-supplied or user-defined function.
      Parentheses following this name are treated as array references and not function
      references.
ERROR: Variable Sep cannot be found on the list of previously defined variables.
ERROR: Too few variables defined for the dimension(s) specified for the array month.
180  DO i=1 to 10;
181  if month(i)=. then month(i)=0;
182  end;
183  run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      178:22   178:40
NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      181:4
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SNOW.SNOWFALL may be incomplete.  When this step was stopped there were 0
         observations and 3 variables.
WARNING: Data set SNOW.SNOWFALL was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


May I ask what did it mean by "a valid member type"?

And what can I do to "Array" command to make this work?

 

Any suggestions and hints would be much appreciated!

 

Thanks very much!

PROC Star
Posts: 1,769

Re: Libref is not assigned

[ Edited ]

first off, this is wrong

data snow.snowfall;
177  set "&dirdata.Tmp4.Snow";

should be

data snow.snowfall;
177  set &dirdata..Tmp4;
 

The naming convention is libref.sasdatasetname

Your libref is snow, so it should be snow.datasetname 

Frequent Contributor
Posts: 112

Re: Libref is not assigned

Posted in reply to novinosrin

Thanks very much!

 

so,

I use my university desk top again to continue,

and I encountered problem again.

(for previous months I'have used Sas Studio because I use Mac

but I got some data sets not easily access so I changed to SAS 9.2

I really need some help..)

 

The same problem again.

It is:

%let dirdata=C:\Users\jc3992\MySASData;
libname snow "&dirdata";
run;

and the LOG is as below:

 

4    %let dirdata=C:\Users\jc3992\MySASData;
5    libname snow "&dirdata";
NOTE: Library SNOW does not exist.
6    run;

I have checked the folder,

it showed it does not exist.

Would you mind helping me out with this ?

I can hardly move on with these issues >"<

Thanks!!

PROC Star
Posts: 1,769

Re: Libref is not assigned

[ Edited ]

Good morning, Give me an hour or so, I have just woken up, Let me get to my college lab and post you some clear demonstrations. I do not have sas at home I'm afraid.

Frequent Contributor
Posts: 112

Re: Libref is not assigned

Posted in reply to novinosrin

I succeeded!^__^

Thanks for your kind help~~

 

May I ask you what command I can use if I am going to combine data to some categories.

For instance, I have a data set listing every single years, months in every year, and quantity of snowfall for each month in each year,

and now I am going to combine these to three columns named "Year" "Month" and "Snowfall"

What would you do with this?

 

Thank you!Smiley Happy

PROC Star
Posts: 1,769

Re: Libref is not assigned

You need to learn the sas concepts of combining datasets. It's not just about command or statement. It's about how you approach a solution with a concept,

 

https://www.albany.edu/~msz03/epi514/notes/p121_142.pdf

 

http://www-personal.umich.edu/~kwelch/b600/2012/Combining%20SAS%20Data%20Sets.pdf

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 1218 views
  • 3 likes
  • 2 in conversation