BookmarkSubscribeRSS Feed
mayasak
Quartz | Level 8

Hi, 

I'm trying to combine two datasets, two from the prelimenary network drive (P) and one from the final network drive (Q, the backend server drive).

I prepared and cleaned the 2 datasets from P and merged them with the Q data set (which was not touched) then I saved the merged set in the P drive. What happened is that all the datasets related to the merged data set do not show up (I mean the data observations, only variables show up) when I opened them in SAS. But when I tried to read them in SAS, all proc contents, proq freqs work, also all the queries still work perfectly on the related website. This means the data is still there but it doesn't show up. Yesterday, I had the same problem and I'm not sure what I did and it showed the obseravations back. Today when I was still manipulating the data and saved  the merged data set I had the same problem again. I have no clue on what's happening, I concatenated two other datasets before and didn't have any problem, could it be the merging the datasets and if that is the case, how should I solve it.

Thank you.

8 REPLIES 8
EastwoodDC
Obsidian | Level 7
It's hard to say without seeing your code. My best guess is you are not viewing what you think you are viewing (perhaps a local data set rather than a permanent one?). I suggest using Proc Datasets to delete any local data once you are done with it, and see if that clears up the problem.
mayasak
Quartz | Level 8

Thank you  for your reply, here's the code I used.

 

libname final "Q:\sasData\final";
options nocenter nonumber nodate linesize=125 pagesize=4000 formchar=" " ;

data brfss1;
set final.brfss04_14_cdc;
run;

libname prelim "P:\BRFSS\data\ORIG\CDC";
data brfss2;
set prelim.nm13finl prelim.nm14finl;
run;

data brfss3;
set brfss2 (rename=(iyear = YEAR decide = _DiffDecide));
run;
data brfss4;
set brfss3 (keep = _DiffDecide RRCLASS2 RRATWRK2 RRCOGNT2 RREMTSM2 RRHCARE3 RRPHYSM2 YEAR SEQNO);
year1 = input(year,4.0);
drop year;
rename year1 = YEAR;
run;

data brfss5;
set brfss4;

_RRCLASS = .;
if RRCLASS2 = 6 then _RRCLASS = 1;
else if RRCLASS2 = 4 OR RRCLASS2 = 5 then _RRCLASS = 2;
else if RRCLASS2 = 2 then _RRCLASS = 3;
else if RRCLASS2 = 3 then _RRCLASS = 4;
else if RRCLASS2 = 1 then _RRCLASS = 5;
LABEL _RRCLASS = "People Classify you: 1=American Indian/Alaska Native, 2=Asian/Pacific Islander, 3=Black/African American, 4=Hispanic, 5=White";

_RRCOGNT = .;
if RRCOGNT2 = 6 then _RRCOGNT = 1;
else if RRCOGNT2 = 5 then _RRCOGNT = 2;
else if RRCOGNT2 = 4 then _RRCOGNT = 3;
else if RRCOGNT2 = 3 then _RRCOGNT = 4;
else if RRCOGNT2 = 2 then _RRCOGNT = 5;
else if RRCOGNT2 = 1 then _RRCOGNT = 6;
LABEL _RRCOGNT = "Thinking About Race: 1=Once an Hour, 2=Once a Day, 3=Once a Week, 4=Once a Month, 5= Once a Year, 6= Never";

_RRATWRK = .;
if RRATWRK2 = 1 then _RRATWRK = 4;
else if RRATWRK2 = 2 then _RRATWRK = 2;
else if RRATWRK2 = 3 then _RRATWRK = 1;
else if RRATWRK2 = 4 then _RRATWRK = 3;
else if RRATWRK2 = 5 then _RRATWRK = 5;
LABEL _RRATWRK = "Feel Treated at Work Due to Race: 1=Better Than Other Races, 2=Same as Other Races, 3=Worse Than Some Races, Better Than Others, 4=Worse Than Other Races, 5=Only Encountered People of The Same Race";

_RRHCARE = .;
if RRHCARE3 = 1 then _RRHCARE = 4;
else if RRHCARE3 = 2 then _RRHCARE = 2;
else if RRHCARE3 = 3 then _RRHCARE = 1;
else if RRHCARE3 = 4 then _RRHCARE = 3;
else if RRHCARE3 = 5 then _RRHCARE = 5;
else if RRHCARE3 = 6 then _RRHCARE = 6;
LABEL _RRHCARE = "Experience at Health Care: 1=Better Than Other Races, 2=Same as Other Races, 3=Worse Than Some Races, Better Than Others, 4=Worse Than Other Races, 5=Only Encountered People of The Same Race, 6=No Health Care in Past 12 Months";

_RRPHYSM = .;
if RRPHYSM2 = 1 then _RRPHYSM = 2;
else if RRPHYSM2 = 2 then _RRPHYSM = 1;
LABEL _RRPHYSM = "Felt Physical Symptoms Due to Race: 1=no, 2=yes";

_RREMTSM = .;
if RREMTSM2 = 1 then _RREMTSM = 2;
else if RREMTSM2 = 2 then _RREMTSM = 1;
LABEL _RREMTSM = "Felt Emotionally Upset Due to Race: 1=no, 2=yes";
run;

data brfss6 (keep = _DiffDecide _RRCLASS _RRATWRK _RRCOGNT _RREMTSM _RRHCARE _RRPHYSM YEAR SEQNO);
set brfss5 (drop = RRCLASS2 RRATWRK2 RRCOGNT2 RREMTSM2 RRHCARE3 RRPHYSM2);
run;

data prelim.brfss;
merge brfss1 brfss5;
by seqno;
run;

 

I've already deleted the merge dataset file that was saved from the P drive and not by using SAS code. Yesterday like I said I had the same problem but it suddenly worked (don't have any clue how) and today I had the problem again.

 

(FYI by not seeing the data, I mean when I double click on it from the P or Q drive; the proc print works just fine)

 


Capture.PNG
EastwoodDC
Obsidian | Level 7

I don't see anything in the code that would cause what you describe.

 

In the last data step though:

merge brfss1 brfss5;

 

Is brfss5 what you mean to merge, or should it be brfss6?

This might cause unexpected results if same-name variables in brfss1 are overwritten.

 

 

mayasak
Quartz | Level 8

The variable names are different though. 

LinusH
Tourmaline | Level 20
So the data sets are there but seems to have no observations?
What does proc contents tell you?
What SAS client are you using?
Data never sleeps
mayasak
Quartz | Level 8

Thank you LinusH. Yes the data sets are there and every thing seems fine but the tmp data ( when I just click on the data file from the P and Q driver) shows only the variable row and no observations. Proc contents, proc print, and proc freq all are working fine. Attached is the proc content.

And as I said yesterday I had the same problem but it worked at some point (I was deleting all dat sets that I saved recently on driver P when data showed again on both drives P and Q; I have no clue how and why) . Today I had the same problem again after I was manipulating, merging and saving the merged dataset on P.  I deleted the new file but still have no data there.


Capture.PNG
LinusH
Tourmaline | Level 20
What SAS client / user interface are you using, and version?
Data never sleeps
mayasak
Quartz | Level 8

SAS 9.4 version, I'm not sure about SAS client.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 2151 views
  • 0 likes
  • 3 in conversation