example of output is above my code: I want the column CHECK_AHIP to allow enough char length for "Ready To Train" to NOT get truncated. I have tried format=$25. in my data step and get the below error. I have also tried Format CHECK_AHIP $25.; but it does not change anything in the output. Can someone suggest a solution please?
99 format=$25.;
____
386
200
ERROR 386-185: Expecting an arithmetic expression.
ERROR 200-322: The symbol is not recognized and will be ignored.
proc sql;
create table medicaresalesagencies3 as
select distinct
a.agency_name,
a.aor_code,
a.agency_type,
/*a.'Level 3'n as 'Level 3'n,*/
/*case
when a.'Level 2'n is null then a.aor_code
else a.'Level 2'n end as 'Level_Down 2'n,*/
case
when a.TOH_agency is null then a.aor_code
else a.TOH_agency end as 'TOH_AGENCY'n,
compbl(strip(cat(propcase(a.agents_name)," ",propcase(a.agents_last_name)))) as agent_name,
a.role,
a.agent_individual_writing_number,
a.license,
a.agent_npn,
/*a.agent_email_address,
a.agent_work_phone_number,*/
/*a.agent_start_date,
a.agent_end_date,*/
/*a.agent_address,
a.agent_address_line_2,
propcase(a.cty_nm) as cty_nm,*/
a.usps_stt_cd,
a.zip_code,
a.county,
a.rts_goals_per_county,
a.broker_managers,
a.assigned_broker_manager,
/*a.country_name,
a.lat_nb,
a.long_nb,*/
a.cms_pass_fail,
a.cms_cert_eff_date,
a.cms_cert_term_date,
a.course_title,
a.certification_status,
b.SITE_LICENSES as AHIP_ON_FILE,
b.ahip_status,
case when role = "Agent" and max(year(CMS_CERT_TERM_DATE)) ne 2022 and b.SITE_LICENSES is missing then 'AHIP Needed' /*else 'AHIP OnFile'*/
end as CHECK_AHIP,
case when role = "Agent" and max(year(CMS_CERT_TERM_DATE)) eq 2022 and b.SITE_LICENSES is not missing then 'RTS 2022'
end as Agents_Status,
case when role = "Agent" and max(year(CMS_CERT_TERM_DATE)) ne 2022 and b.SITE_LICENSES is not missing then 'Ready To Train' /*else 'Not RTT'*/
end as TRAIN_INDICATOR
from medicaresalesagencies2 a
left join cpm1p1.ahip_dmp b
on a.agent_npn = b.npn
where a.aor_code not in ('K001','K003')
/*and a.role in ('Agent')*/
group by
a.agent_npn
order by a.aor_code asc;
/* AHIP_Submission asc;*/
quit;
data medicaresalesagencies3;
set medicaresalesagencies3;
if CHECK_AHIP='' and Agents_Status='' and TRAIN_INDICATOR='' then CHECK_AHIP='';
if CHECK_AHIP='AHIP Needed' and Agents_Status='' and TRAIN_INDICATOR='' then CHECK_AHIP = 'AHIP Needed';
if CHECK_AHIP='' and Agents_Status='RTS 2022' and TRAIN_INDICATOR='' then CHECK_AHIP='RTS 2022';
if CHECK_AHIP='' and Agents_Status='' and TRAIN_INDICATOR='Ready To Train' then CHECK_AHIP = 'Ready To Train';
format CHECK_AHIP $25.;
run;
This is not a format issue but a LENGTH issue.
Try this:
case when role = "Agent" and max(year(CMS_CERT_TERM_DATE)) ne 2022 and b.SITE_LICENSES is missing
then 'AHIP Needed' /*else 'AHIP OnFile'*/ end as CHECK_AHIP length=25
You should use the `length = ` option in a PROC SQL query. Here's an example -- your code is pretty long so I just made a fake example:
proc sql;
create table want as
select
*,
case when make = "Toyota" then "It's a Toyota!"
when make = "Ford" then "Ford!"
else "What kind of car is this?"
end as test_var length = 25
from
sashelp.cars;
quit;
Unless you have a format that's already specified in a PROC FORMAT step.
Thank you for the example!
This is not a format issue but a LENGTH issue.
Try this:
case when role = "Agent" and max(year(CMS_CERT_TERM_DATE)) ne 2022 and b.SITE_LICENSES is missing
then 'AHIP Needed' /*else 'AHIP OnFile'*/ end as CHECK_AHIP length=25
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.