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

Hello all,

I have updated variables in this data set, but am not able to run regressions. 

 

I imported a .dta file to SAS and it is not a mydata.sas7bdat file but, I have not idea how to 'read it in' because we've been using INFILE for .txt files all semester.. I tried an alternative approach to accessing the .dta file but anyway, I need to fix how I've brought the data in so that I can run regressions (see below). 

 

libname mylib '/home/xxxxxxxxxx/sasuser.v94';
proc import out=mylib.mydata datafile='/home/xxxxxxxxxxxxxx/2019 ASR_Public_Use_File.dta' dbms=DTA replace;
run;

proc print data=mylib.mydata;
run;

proc freq data=mylib.mydata;
table _all_;
run;

proc means data=mylib.mydata;
run;

proc contents data=mylib.myformats varnum;
run;
/********************************************************/
/*ATTEMPT TO ACCESS #2*/
proc import out=ASR1 datafile='/home/xxxxxxxxxxx/sasuser.v94/Final Project/2019 ASR_Public_Use_File.dta'
run;

proc contents data=ASR1;
run;

data asr;
set ASR1;
run;
/*** I can make the below edits but then later, running a regression doesn't work***/

data asrworking;
set asr(keep=personid numppl qn1f qn1d qn1c qn2a qn4c qn26h qn31f_months qn1jyear qn28a);
run;

data asrworking;
set asrworking;
rename qn1f=sex;
rename qn1d=age;
rename qn1c=married;
rename qn2a=school;
rename qn4c=english;
rename qn26h=childed;
rename qn31f_months=tanf;
rename qn1jyear=arrived;
rename qn28a=health;
run;

data asrworking;
set asrworking;
IF (arrived= .) THEN DELETE;
run;

This is the LOG for the resultant error when I try a simple OLS regression: 

388        proc reg data=asrworking;
 389        model tanf = male age marr educ engl ceduc d14 d15 d16 d17 d18 healthy numppl / acov hccme=0;
 390        ods output ParameterEstimates=beta.hats;
 391        run;
 
 ERROR: Libref BETA is not assigned.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE REG used (Total process time):
       real time           0.06 seconds
       user cpu time       0.06 seconds
       system cpu time     0.00 seconds
       memory              2656.12k
       OS Memory           28096.00k
       Timestamp           08/03/2023 03:16:06 AM
       Step Count                        420  Switch Count  2
       Page Faults                       0
       Page Reclaims                     313
       Page Swaps                        0
       Voluntary Context Switches        17
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           312
       
 392        
 393        
 394        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 404        

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

The error message is pretty clear: You're trying to create a table hats under library beta but you don't have a libname statement in your code that assigns such a library.

Patrick_0-1691035242955.png

 

For testing purposes: Change beta.hats to WORK.hats and see what happens.

View solution in original post

6 REPLIES 6
Patrick
Opal | Level 21

The error message is pretty clear: You're trying to create a table hats under library beta but you don't have a libname statement in your code that assigns such a library.

Patrick_0-1691035242955.png

 

For testing purposes: Change beta.hats to WORK.hats and see what happens.

ameliasalem
Obsidian | Level 7

That did it and I have the below output - Any time that I would typically use beta then, would I need to use, 'Work'? Would this impact my use of the term 'beta' for labeling parameters when I need to explicitly define exogenous and endogenous variables, etc.,?

ameliasalem_0-1691036512515.png

 

ameliasalem
Obsidian | Level 7
This is what we have been initially trained to use so I am still learning what each character does, or does not do, in SAS.
Tom
Super User Tom
Super User

@ameliasalem wrote:
This is what we have been initially trained to use so I am still learning what each character does, or does not do, in SAS.

SAS names are pretty simple.  You can use letters, digits and the underscore character.  You cannot start a name with a digit.  And the name of a FORMAT or INFORMAT cannot end with a digit (the digits at the end of a format specification is the particular width you want to use this time.).

 

SAS names can now be up to 32 bytes long, except for filerefs or librefs which are defined by FILENAME or LIBNAME statements.  Those can still only use the original 8 byte limit. 

ameliasalem
Obsidian | Level 7
Awesome, this is super helpful. Thank you!

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
  • 6 replies
  • 1180 views
  • 2 likes
  • 4 in conversation