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
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.
For testing purposes: Change beta.hats to WORK.hats and see what happens.
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.
For testing purposes: Change beta.hats to WORK.hats and see what happens.
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.,?
What should be the meaning of "beta" then? If you want it to be part of the dataset name, do not use a dot, use an underline.
@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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.