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

Hi all,

I am trying to regroup my data using various formats that I already created. However, when I put it in my proc sql code, the formats just didn't seem to work. The log shows nothing wrong when I ran the formats and the sql code and the sql code produced results with no problem (just not formatted the way i want...) I can't quite figure out what I did wrong and hope someone could provide some feedbacks!

Thank you!

Libname FORMAT '/folders/myshortcuts/myFolder';
Proc format lib=FORMAT;
value SPDlevel 1= "4"
			   2= "3"
			   3= "2"
			   4= "1"
			   5= "0"
			   .="missing"
			   other= "missing"
;
run;

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;
value race 5="missing";
run;		   

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;			   
value SPDgroup 0-12= "0"
			   13-high= "1"
			   .="missing"
			   other="missing"
;
run;

Proc sql;
create table work.adult2010 as 
select Sex,
cat(RECTYPE, SRVY_YR, HHX, FMX,FPX) as ID,
AGE_P as AgeGroup format=agegroup.,
RACERPI2 as Race format=race.,
SAD as SAD format=SPDlevel.,
NERVOUS as NERVOUS format=SPDlevel.,
RESTLESS as RESTLESS format=SPDlevel.,
HOPELESS as HOPELESS format=SPDlevel.,
EFFORT as EFFORT format=SPDlevel., 
WORTHLS as WORTHLS format=SPDlevel.,
sum(SAD, NERVOUS,RESTLESS, HOPELESS,EFFORT,WORTHLS) as K6SUM,
calculated K6SUM as SPD format=SPDgroup.
from new.adult2010;
quit;
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

You are missing the FMTSEARCH option to tell SAS where to pick up your new formats:

options fmtsearch = (WORK, FORMAT, LIBRARY);

This statement tells SAS to search the libraries WORK, FORMAT and LIBRARY for a format catalog called FORMATS.

 

BTW you only need one LIBNAME statement.

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

You are missing the FMTSEARCH option to tell SAS where to pick up your new formats:

options fmtsearch = (WORK, FORMAT, LIBRARY);

This statement tells SAS to search the libraries WORK, FORMAT and LIBRARY for a format catalog called FORMATS.

 

BTW you only need one LIBNAME statement.

cheungmonica
Calcite | Level 5
Thank you so much! It worked right after that!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1560 views
  • 0 likes
  • 2 in conversation